I have designed tabs using the <button>
element and enclosed the tab content within separate <div></div>
tags like shown below:
function displayTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
<button class="tablinks" onclick="displayTab(event, 'Tab1')">Tab1</button>
<button class="tablinks" onclick="displayTab(event, 'Tab2')">Tab2</button>
<div id="Tab1" class="tabcontent">
<h5>Title</h5>
<div class="a">
<p>Content</p>
</div>
</div>
By default, all contents are initially hidden. In order to display Tab1 by default, how can I modify the script?