Skip to content

Instantly share code, notes, and snippets.

@bulbul84
Created February 22, 2017 15:43
Show Gist options
  • Save bulbul84/5cef3b691521c2e9e5215a694ba1ca96 to your computer and use it in GitHub Desktop.
Save bulbul84/5cef3b691521c2e9e5215a694ba1ca96 to your computer and use it in GitHub Desktop.
Changes/Add and Remove class by click, jquery tricks
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