This is my navigation bar. I am trying to use JavaScript or jQuery to retrieve the current page's URL and open the corresponding dropdown container. I want to display the relevant section of the side navigation based on the URL. I have tried writing this JavaScript code, but it doesn't seem to be working.
$(function() {
if (window.location.href.indexOf("home") > -1)
$('.dropdown-toggle.home').dropdown('toggle');
else if (window.location.href.indexOf("FRAMEWORKS") > -1)
$('.dropdown-toggle.FRAMEWORKS').dropdown('toggle');
else if (window.location.href.indexOf("Strategize phase") > -1)
$('.dropdown-toggle.Strategize phase').dropdown('toggle');
else if (window.location.href.indexOf("Standardize phase") > -1)
$('.dropdown-toggle.Standardize phase').dropdown('toggle');
else if (window.location.href.indexOf("Implement phase") > -1)
$('.dropdown-toggle.Implement phase').dropdown('toggle');
else if (window.location.href.indexOf("Integrate phase") > -1)
$('.dropdown-toggle.Integrate phase').dropdown('toggle');
else (window.location.href.indexOf("About") > -1)
$('.dropdown-toggle.ABOUT').dropdown('toggle');
});
Home
<button id class="dropdown-btn FRAMEWORKS" href="#">FRAMEWORKS <i class="fa fa-caret-down"></i></button>
<div class="dropdown-container">
<div class="sub">
<a href="#">Framework</a>
<button class="dropdown-btn" href="#">Strategize phase<i class="fa fa-caret-down"></i></button>
<div class="dropdown-container">
<div class="subSub">
<a href="#">Enterprise Innovation Audit Canvas</a>
<a href="#">Pre-Audit Business Definition Questions</a>
<button class="dropdown-btn" href="#">Tools and Canvases for the Enterprise Innovation Capability Audit<i class="fa fa-caret-down"></i></button>
<div class="dropdown-container">
<div class="subSubSub">
<a href="#">Enterprise Innovation Maturity Canvas</a>
<a href="#">Enterprise Innovation Maturity Evaluation Grid Canvas</a>
<a href="#">Enterprise Innovation Maturity Road map Canvas</a>
</div>
</div>
</div>
</div>
</div>
<button class="dropdown-btn" href="#">Standardize Phaze<i class="fa fa-caret-down"></i></button>
<div class="dropdown-container">
<div class="subSub">
<button class="dropdown-btn" href="#">Innovation Culture Fostering Approach<i class="fa fa-caret-down"></i></button>
<div class="dropdown-container">
<div class="subSubSub">
<a href="#">Innovation Fostering Approach Summary</a>
<a href="#">4I- Inspire, Ideate, Implement and Impact Enterprise Innovation Fostering Model</a>
<a href="#">Enterprise Team Inventiveness Persona</a>
</div>
</div>