Skip to content

@stylephreak /jQuery.fn.attrToClass
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
jQuery function that appends a class to each designated element by pulling it from a tag attribute.
//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.