Consider this scenario, where a menu is presented:
function toggleHiddenContent(tabClass) {
let t = document.querySelectorAll(tabClass);
for(var i = 0; i<t.length; i++) {
t[i].classList.toggle="visible-class";
}
}
.hidden-content {
display: none;
}
.visible-class {
display: block
}
<div>
<a class="main-holder" onClick="toggleHiddenContent('.main-holder')">Main one</a>
<div class="hidden-content">Hidden content One</div>
<a class="main-holder" onClick="toggleHiddenContent('.main-holder')">Main two</a>
<div class="hidden-content">Hidden content two</div>
</div>
Despite the functionality, it currently toggles all classes. I am aware of the issue, but I am seeking a method to target only the clicked element and not those untouched. Any ideas on how to achieve this using vanilla javascript?
Your assistance would be greatly appreciated.