Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Quick jQuery plugin to parse data from an element and store it on the element via
$.fn.parseData = function(){
return $(this).filter('[js-data]').each(function(){
var data = jQuery.parseJSON($(this).attr('js-data')), prop;
for(prop in data)
$(this).data(prop, data[prop]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment