I have the following list:
<!-- List -->
<ul class="nav nav-sm nav-tabs nav-vertical mb-4 steps-sampling">
<li class="nav-item">
<a class="nav-link active" id="link1" href="{{ url_for('overview') }}">
<i class="bi-list-check nav-icon"></i>Overview
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('upload') }}">
<i class="bi-file-arrow-up nav-icon"></i> Upload file
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('choose_numeric') }}">
<i class="bi-sort-numeric-down nav-icon"></i> Choose the numeric column
</a>
</li>
</ul>
It starts with the first list element as active. I want to change the active
state based on the list element which is clicked.
I tried:
$('.steps-sampling').on('click','a', function(){
$(this).addClass('active').siblings().removeClass('active');
});
And (added id to anchor tag)
//on first time load set the home menu item active
$(".steps-sampling a#link1").addClass("active");
//on click remove active class from all li's and add it to the clicked li
$("a").click(function(){
$("a").removeClass("active");
$(this).addClass("active");
});
But both do not work.
This is the .active class I could find for nav-link. I only have access to the min.css
so it is kind of hard to find (not sure if this is sufficient)
.nav-link.active{border-color:#006673}
I cannot add active
to the li
element since it does not seem to work with the Bootstrap template I am using.
How can I solve this?