Skip to content

Instantly share code, notes, and snippets.

@AlifArnado
Created August 10, 2020 08:30
Show Gist options
  • Save AlifArnado/e960843bd9203b64a78af2692024a613 to your computer and use it in GitHub Desktop.
Save AlifArnado/e960843bd9203b64a78af2692024a613 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
/** add active class and stay opened when selected */
var url = window.location;
// for sidebar menu entirely but not cover treeview
$('ul.nav-sidebar a').filter(function() {
return this.href == url;
}).addClass('active');
// for treeview
$('ul.nav-treeview a').filter(function() {
return this.href == url;
}).parentsUntil(".nav-sidebar > .nav-treeview").addClass('menu-open').prev('a').addClass('active');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment