Reputation: 631
I have a nav menu that opens (and closes) on-click.
I want the menu to be always open (without having to click) when a specific page loads.
It's currently set up as:
$('.menu').on('click', function() {
$('.menu').toggleClass('active');
$('nav').toggleClass('active');
});
I'm not sure how to get it to stay active on a specific page load.
I've tried this but can't get it to work.
if(window.location.href.indexOf("get-started")
$('.menu').toggleClass('active');
$('nav').toggleClass('active');
});
Upvotes: 0
Views: 152
Reputation: 91
Please try below code:
if(window.location.href.indexOf("get-started") {
$('nav').addClass('active');
}
Add this code directly in document.ready.
Upvotes: 1