Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

jQuery function that appends a class to each designated element by pulling it from a tag attribute.

View jQuery.fn.attrToClass
1 2 3 4 5 6 7 8 9 10 11 12
//Appends a class to each designated element by pulling it from a tag attribute.
jQuery.fn.attrToClass = function(attribute) {
$(this).each(
function(intIndex){
$(this).addClass($(this).attr(attribute));
});
};
 
$(document).ready(function(){
// designate the tag and the attribute to be extracted
$("input").attrToClass("type");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.