I want to store server-side Id(s) of items within an attribute defined on <li> tags, such that I could retrieve them within JS methods when there is a click event on them.
Is there any attribute that I could use to store this kind of data?
I tried putting server side ids of items into id attribute of <li> tags but it doesnt allow ids starting with digits
!
HTML5 introduces
data-attributes which can be very useful in cases such as this one.Then, in JavaScript, you can fetch using:
or (not IE supported):
http://jsfiddle.net/9g33e/