Return to Snippet

Revision: 12506
at March 17, 2009 18:19 by stylephreak


Initial Code
jQuery.fn.attrToClass = function(e) {
	$(this).each(
		function(intIndex){
		    $(this).addClass($(this).attr(e));
	});
};
 
$(document).ready(function(){
        // designate the tag and the attribute to be extracted
	$("input").attrToClass("type");
});

Initial URL
http://www.stylephreak.com/blog/coding/attrtoclass-jquery-plugin/

Initial Description
Appends a css class to all form input elements on a page by extracting the input type from the element in question.

Initial Title
jQuery.attrToClass

Initial Tags
jquery

Initial Language
jQuery