When I saw this, it totally blew my mind! I now think back on all the times that I have completely misused REL or ID or TITLE attributes to store critical pieces of data (that were not really REL, ID, or TITLE data respectively). It makes me feel so dirty; there's been this jQuery Data() method sitting there the whole time, doing exactly what I need it to do, and I've just been disrespecting the DOM left and right to achieve my own ends.
As shown in the demonstration above, I set up a small test page to explore the jQuery Data() method. In it, I am basically setting up several links, associating data with them, and then alerting that associated data when the respective link is clicked:
No comments:
Post a Comment