This jQuery extension allows for a cleaner way to pull html data attributes out of elements with jQuery.
Data such as:
<a id = 'testId' href = '#' data-test = 'test!'>This is a test</a>
Can easier be accessed now with:
jQuery('#testId').dataAttr('test'); => 'test!'
Or set as:
jQuery('#testId').dataAttr('test', value);
Just include the source after loading jQuery, thats it.
<script src="jquery.js"></script>
<script src="html5data.jquery.js"></script>
Copyright © 2010 Erick Schmitt, released under the MIT license.