Created
February 22, 2017 15:43
-
-
Save bulbul84/5cef3b691521c2e9e5215a694ba1ca96 to your computer and use it in GitHub Desktop.
Changes/Add and Remove class by click, jquery tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(window).load(function(){ | |
/* List table sort columns */ | |
$('.button-collapse').on('click', function (e) { | |
e.preventDefault(); | |
$(this).toggle2classes("menuOpen", "menuClose"); | |
}); | |
$.fn.toggle2classes = function(class1, class2){ | |
if( !class1 || !class2 ) | |
return this; | |
return this.each(function(){ | |
var $elm = $(this); | |
if( $elm.hasClass(class1) || $elm.hasClass(class2) ) | |
$elm.toggleClass(class1 +' '+ class2); | |
else | |
$elm.addClass(class1); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment