A simpler meta data plugin for jQuery
I needed a simple way to get meta data about an element into a javascript so I started using John Resig’s Metadata plugin for jQuery but found it to be a lot more heavy handed then what I needed. I also wanted the data to be available in jQuery’s standard data hash as apposed to a separate place. So I wrote a simpler meta data plugin.
Example:
<div id="user" data="{username:'loverboy34',age:13,alive:true}">whatever</div>
$(function(){
console.log('username:', $('#user').data('username'));
console.dir($.cache[ $.data($('#user').get()[0]) ]);
});
It weighs in at 57 lines and works great. enjoy.
0 notes
POSTED Friday November 13th