Created
November 3, 2014 10:35
-
-
Save akmur/64180ab6aaa9f608b7e1 to your computer and use it in GitHub Desktop.
Remove All Data Attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('div').each(function(index, el) { | |
// Fetch an array of all the data | |
el = $(el); | |
var data = el.data(), | |
i; | |
// Fetch all the key-names and put them in a variable called keys | |
var keys = $.map(data , function(value, key) { return key; }); | |
// Loop through the keys, remove the attribute if the key contains "lorem". | |
for(i = 0; i < keys.length; i++) { | |
el.removeAttr("data-" + keys[i]); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment