Skip to content

Instantly share code, notes, and snippets.

@aziz-blr
Created July 12, 2017 11:52
Show Gist options
  • Save aziz-blr/4de1d7baaace1ceeed41ecaaeee8faf0 to your computer and use it in GitHub Desktop.
Save aziz-blr/4de1d7baaace1ceeed41ecaaeee8faf0 to your computer and use it in GitHub Desktop.
To make Menu or Sub Menu active according to URL of page
var path = window.location.href;
$('.sidebar-menu li a').each(function () {
// Account for home page with empty path
if (path == 'http://localhost/alshaheedpark/admin/') {
path = path + 'index.php';
}
if (this.href === path) {
$(this).parent().addClass('active');
}
});
$('.treeview-menu li a').each(function () {
// Account for home page with empty path
if (path == 'http://localhost/alshaheedpark/admin/') {
path = path + 'index.php';
}
if (this.href === path) {
$(this).parent().addClass('active');
$(this).parent().parent().parent().addClass('active');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment