Skip to content

Instantly share code, notes, and snippets.

@monir-dev
Created November 25, 2018 06:25
Show Gist options
  • Save monir-dev/71641e74b02499595578fb699df06f72 to your computer and use it in GitHub Desktop.
Save monir-dev/71641e74b02499595578fb699df06f72 to your computer and use it in GitHub Desktop.
$(document).on("click", ".yourClass", function() {
var links = document.getElementsByClassName('nav-menu');
for (var i = 0; i < links.length; i++){
var now = links[i];
if(now.className.includes("active")) {
now.classList.remove("active");
}
}
this.className += ' active';
});
// Instruction
// 1. Give you menus a class. in my case it is yourClass
// you are all done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment