rob86 Posted August 25, 2009 Report Share Posted August 25, 2009 I'm not sure how to explain this, but I have a <div> box but it could be an image or anything what it is isn't too important I don't think. I want to be able to store just a simple hidden numerical value in it (a rating from 1-100 for example) and then be able to extract it later for use elsewhere in the code, in a javascript tooltip for example. I haven't been able to figure out how to do this but I was reading a bit about the HTML DOM which looked like it might be useful. Any suggestions ?Another example is if I had an image of 4/5 stars, which when hovered over would be able to make a tooltip that says" The score is 4 out of 5". because the 4 was stored somehow.I'm not actually at the stage of making a tool tip or anything now, just trying to figure out how to get a number out of the object. Link to comment Share on other sites More sharing options...
Ingolme Posted August 25, 2009 Report Share Posted August 25, 2009 You can use attributes to store information. For links, you can use rel and rev, for other elements, you can use class, though that can conflict with actually classes assigned to the object. If there aren't any existing attributes you can use, you can make one up: elements.setAttribute('customAttribute','value'); To access information from an attribute, use getAttribute(): alert(elements.getAttribute('customAttribute')); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now