/ Published in: jQuery
Appends a css class to all form input elements on a page by extracting the input type from the element in question.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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"); });
URL: http://www.stylephreak.com/blog/coding/attrtoclass-jquery-plugin/