I'm a JS n00b, so my apologies for asking something so simple. (It's so simple that the rest of SO is providing more complex answers than I need.) I have a JSON array like this:
var comics = {"spider":"Spiderman", "bat":"Batman", "super":"Superman", "aqua":"Aquaman"};
And I want to access items in that array from another array, like so:
var childhood_heroes = {"fire":"Firefighters", "jordan":"Michael Jordan", "superhero":[comics.super, comics.bat]};
I'm attaching it with jQuery to a div in my HTML with:
$('#which_heroes').click(function() {
$('#jobs').html(childhood_heroes.fire);
$('#sports').html(childhood_heroes.jordan);
$('#supers').html(childhood_heroes.superhero);
});
The first two work when the third is absent. The presence of the third breaks everything. What am I doing wrong?
superheroes
were["super", "bat"]
, instead of explicit references. – Jason McCreary Jun 23 '11 at 16:16[comics.super, comics.bat]
withcomics.super +' '+ comics.bat
– Val Jun 23 '11 at 16:17