Answer the question
In order to leave comments, you need to log in
How to set several different buttons to open one tab?
<script>
function openTab(evt, name) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(name).style.display = "flex";
evt.currentTarget.className += " active";
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
Answer the question
In order to leave comments, you need to log in
20 Mbps in frames of 1250 bytes
6 Mbps in frames of 125 bytes
... we count how many packets (frames) in each of the options ... we calculate k
<ul>
<li class="tablinks" data-index="1">1</li>
<li class="tablinks" data-index="2">2</li>
<li class="tablinks" data-index="3">3</li>
</ul>
<div class="tabcontainer">
<div class="tabcontent">
1
</div>
<div class="tabcontent">
2
</div>
<div class="tabcontent">
3
</div>
</div>
<a href="#" data-index="2">2</a>
function openTab(curIndex) {
const tabcontent = document.getElementsByClassName('tabcontent');
tabcontent.forEach((one, index) => {
one.style.display = index != curIndex ? 'none' : 'flex';
});
const tablinks = document.getElementsByClassName('tablinks');
tablinks.forEach((one, index) => {
if (index != curIndex) one.classList.remove('active');
else if (!one.classList.has('active')) one.classList.add('active');
});
}
const links = document.querySelector('[data-index]');
links.forEach(one => {
one.addEventListener('click', () => openTab(one.dataset.index));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question