Javascript:
var json = {item1: {foo:bar},item2: {foo:bar)};
$('li').click(function() {
var liID = $(this).attr('id'); // Outputs 'item1' or 'item2'
var theFooValueIWant = json.liID.foo;
});
Pretty simple. I'm trying to get the value of the foo based off the ID of the <li> that gets clicked. But json.liID.foo looks for a liID in the json, which doesn't exist. How do I get it to look for json.the-value-of-liID instead of json.liID itself? Thanks!