• flickr
  • linkedin
  • twitter
  • rss
Adding data to divs with jQuery

Adding data to divs with jQuery

I am only beginning to experiment with JS with more depth, and have discovered jQuery has a data function which lets you store data against individual divs. Really useful for some bits and peices!

$("#box0").data("uniqueID", 0);
$("#box1").data("uniqueID", 1);

Then to call it,

$("#box0").click(function() 
{
alert($(this).data("uniqueID"));

I’ll find out how to loop that through a set soon enough – very similar to AS3, handy.

src
http://www.queness.com/post/7050/8-jquery-methods-you-need-to-know

Tech Reference:

Larry's a 30-something chap interested in travel, being a dork and changing the world via less boring training.

Leave a reply