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:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑