I have a function to load page’s dynamically on what’s clicked on by the user.
These menu’s where the users can click, have a HTML/CSS class like this:
– nav-link– nav-link active
When the keyword ‘active’ is added to the class, the menu item is shown like this:
[https://i.paste.pics/badb2ec6458de892013203cdd0d07a35.png?trs=a7cbe7d8460a1e31fc97cb8f1d2037fa254d88bb1b2dc3d9f7efa0d416529a25
The menu item Dashboard is active by default.
When I click on another menu item, this code is getting called:
`function LoadPageEx(that, page) {
LoadPage(page);
$(that).removeClass(‘nav-link’);
$(that).addClass(‘nav-link active’);
}
And the result is this:
[https://i.paste.pics/594580a7d458bb6fcfe69279477a4ba9.png?trs=a7cbe7d8460a1e31fc97cb8f1d2037fa254d88bb1b2dc3d9f7efa0d416529a25
The menu links code:
`<!– Sidebar Menu –>
<nav class=”mt-2″>
<ul class=”nav nav-pills nav-sidebar flex-column” data-widget=”treeview” role=”menu” data-accordion=”false”>
<!– Add icons to the links using the .nav-icon class
with font-awesome or any other icon font library –>
<li class=”nav-item has-treeview menu-open”>
<a href=”#” class=”nav-link active”>
<i class=”nav-icon fas fa-tachometer-alt”></i>
<p>
Dashboard
<i class=”right fas fa-angle-left”></i>
</p>
</a>
<ul class=”nav nav-treeview”>
<li class=”nav-item”>
<a id=”main” href=”#” class=”nav-link active” onclick=”LoadPageEx(this, ‘dashboard.php’)”>
<i class=”far fa-circle nav-icon”></i>
<p>Get Started</p>
</a>
</li>
<li class=”nav-item”>
<a href=”#” class=”nav-link” onclick=”LoadPageEx(this, ‘dashboard.php’)”>
<i class=”far fa-circle nav-icon”></i>
<p>Characters</p>
</a>
</li>
<li class=”nav-item”>
<a href=”?p=punhistory” class=”nav-link”>
<i class=”far fa-circle nav-icon”></i>
<p>Punishment History</p>
</a>
</li>
<li class=”nav-item”>
<a href=”?p=apps” class=”nav-link”>
<i class=”far fa-circle nav-icon”></i>
<p>Quiz Applications</p>
</a>
</li>
</ul>
</li>
<li class=”nav-item”>
<a href=”logout” class=”nav-link”>
<i class=”nav-icon fas fa-th”></i>
<p>
Logout
</p>
</a>
</li>
</ul>
</nav>
<!– /.sidebar-menu –>
What I’m looking to do now is that when LoadPageEx is executed, the other menu items will automatically be set to not active. But how do I do this? I know by using this I can get the current elementid but how can I make all of them inactive when the function is executed?
If it’s of any use, I’m using the Admin LTE3 template for this website.