jquery swapclass


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



Copy this code and paste it in your HTML
  1. $.fn.swapClass = function(c1, c2){
  2. return this.each(function(){
  3. var t = $(this);
  4. (!t.is('.'+c1)) ?
  5. t.addClass(c1).removeClass(c2) : t.addClass(c2).removeClass(c1);
  6. });
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.