[ tabs.js]
【Javascript version】
let tabs = document.getElementsByClassName('tab-control');
let panels = document.getElementsByClassName('tab-panel');
for(let i=0; i<tabs.length; i++) {
tabs[i].addEventListener('click',function(e){
e.preventDefault();
for(let j=0; j<tabs.length; j++) {
tabs[j].parentNode.setAttribute('class', '');
}
this.parentNode.setAttribute('class','active');
let link = this.getAttribute('href');
link = link.substring(1,6);
for(let j=0; j<tabs.length; j++) {
panels[j].style.display = 'none';
}
document.getElementById(link).style.display = 'block';
},false);
}
沒有留言:
張貼留言