Posted By


stylephreak on 03/17/09

Tagged


Statistics


Viewed 317 times
Favorited by 0 user(s)

jQuery.attrToClass


/ Published in: jQuery
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. jQuery.fn.attrToClass = function(e) {
  2. $(this).each(
  3. function(intIndex){
  4. $(this).addClass($(this).attr(e));
  5. });
  6. };
  7.  
  8. $(document).ready(function(){
  9. // designate the tag and the attribute to be extracted
  10. $("input").attrToClass("type");
  11. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.