Hi I'm trying to put the active tab in bold. I think I'm missing something. So here is my tabs:
<div class="nav">
<span id="tab1">tab1</span>| <span id="tab2">tab2</span>| <span id="tab3">tab3 </span>
</div>
<div id="body">
<p> </p>
</div>
I would like that when I click on "tab1" it becomes bold and displays the text that correspond to it. When I click on "tab2" it becomes bold, and the others not. etc.
So Here is what I did:
document.getElementById("tab1").onclick = function () {
document.querySelector("span").classList.remove('active');
document.getElementById("tab1").classList.add('active');
document.getElementById("body").innerHTML = "hello";}
document.getElementById("tab2").onclick = function () {
document.querySelector("span").classList.remove('active');
document.getElementById("tab2").classList.add('active');
document.getElementById("body").innerHTML = "hello2";}
document.getElementById("tab3").onclick = function () {
document.querySelector("span").classList.remove('active');
document.getElementById("tab3").classList.add('active');
document.getElementById("body").innerHTML = "hello3";}
And the css I added:
.active {
font-weight: 700;
}