This is my first post on stackoverflow, so I apologize if my question isn't clear, or this has been answered before. I did try to look, but I think my issue is that I don't know what I'm doing wrong.
I currently have an object, like so:
var character = { name1: { info1: xx, info2: xx, ID: xx}, name2: { info1:
xx, info2: xx, ID: xx} }
I have an image that someone can click on, and that image has IDs that match the object IDs.
I'm trying to transfer the click attribute(ID) to a variable, parse it, then use it to access the more complete id information...like so:
var clickedOnId = $(this).attr("id");
function characterID() {
var parseID = JSON.parse(clickedOnID)
var accessID = character.name.parseID
$(".div").html("<h2>" + accessID + "</h2>")
}
I know the click is logging the ID (I've console.log'ed it), so I know the click is receiving the ID attribute information from the image...so the problem has to do with how i'm accessing the object. I've tried not parsing it too, but that doesn't work. Does anyone have any suggestions for what I could do?
Thank you!
character.namein json you actually have name1, name2 etc.