I currently have a json object, that I loop through and output a list of links.
See fiddle:
http://jsfiddle.net/jasonday/hzZ8j/
each link is given an id based upon the storeID in the json.
What I want to do, is when a link is clicked it finds the id in the json, and then writes the sibling element “otherData” to #otherDataDiv
I’ve worked with traversing xml, but I’m not sure how to accomplish this with json.
Any help would be appreciated. thanks.
You just have to loop over, like this:
However, if you were using jQuery templates then you could just look for ‘tmplItem’ in the data array on the element.
Additionally, if you weren’t building the HTML manually for this, I would suggest using jQuery data here for this project. It would solve your problem immensely.
to store:
$(selector).data('unique name here',data);to retrieve:
var usefulname = $(selector).data('unique name here');and then in your onclick for each link you could: