I am facing an issue with my tab component in plain JavaScript. The content displays correctly in debug mode, but after compilation, it does not show up on the browser. Additionally, when I select a tab, the 'activeNav' class is applied to indicate the active state, but it disappears once the page fully loads. Can someone help me identify what I may be doing wrong?
function selectTab(evnt, targetBlock) {
var i;
var elementList = document.getElementsByClassName("displayContent");
for (i = 0; i < elementList.length; i++) {
if (elementList[i].id === targetBlock) {
elementList[i].style.display = "inherit";
}
}
evnt.currentTarget.classList.add("activeNav");
}
.displayContent {
display: none;
border: 1px solid #efefef;
background-color: pink;
}
.active {
display: inherit;
}
.activeNav {
border: 1px solid red !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav nav-tabs">
<li><a class="a" href="" onclick="selectTab(event, 'Tabtitle-1')">Tab title 1</a></li>
<li><a class="a" href="" onclick="selectTab(event, 'Tabtitle-2')">Tab title 2</a></li>
<li><a class="a" href="" onclick="selectTab(event, 'Tabtitle-3')">Tab title 3</a></li>
</ul>
<div id="Tabtitle-1" class="displayContent">
<p>Content Block 1</p>
</div>
<div id="Tabtitle-2" class="displayContent">
<p>Content Block 2</p>
</div>
<div id="Tabtitle-3" class="displayContent">
<p>Content Block 3</p>
</div>