I have the below code
<li class="nav-item">
<a class="nav-link" href="#" onclick="showNotConfirmedDiv()">
<span data-feather="file-text"></span>
Not Confirmed<span class="badge updateBadge">1</span>
<!-- TODO ONLY SHOW BADGE IF THERE IS A NUMBER!!!!! -->
</a>
</li>
I want the add active to the class for the anchor tag when I hit the li.a tag
<li class="nav-item">
<a class="nav-link active" href="#" onclick="showNotConfirmedDiv()">
<span data-feather="file-text"></span>
Not Confirmed<span class="badge updateBadge">1</span>
<!-- TODO ONLY SHOW BADGE IF THERE IS A NUMBER!!!!! -->
</a>
</li>
This is the JS function I am using..
function showNotConfirmedDiv(e) {
$('#notConfirmedDiv').show();
$('#duplicantClientFilesDiv').hide();
e.classList.add('active');
}
>Solution :
<a class="nav-link" href="#" onclick="showNotConfirmedDiv(this)">
you are not passing e parameter in your function showNotConfirmedDiv is not receiving any element reference when the function is called and this refers to the current context,