Is there a way to have html point to a javascript object?
I know I could have a hash in JS to associate the tag id (or some other attribute) with the JS object, but is there a way to add the pointer to the html tag to the JS object?
<div id="user10"></div>
<div id="user11"></div>
then in JS have
function getUserPointedByTag(tag){
//this is what I would like to have without going through a hash
}
function myAwesomeUserDivClickHandler(clickedTag){
user = getUserPointedByTag(clickedTag)
}
I think you’re better off using
data-attributes to store the user ID in.That way, you can easily retrieve the user ID associated with an element using: