~ruther/blog

ref: 1e4dd2e3a3a3029087f7d501e0715d4756ff8a78 blog/themes/poison/assets/js/tabs.js -rw-r--r-- 787 bytes
1e4dd2e3 — Rutherther chore: add rsync 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const tabs = document.querySelectorAll(".tab")
  
tabs.forEach(tab => {
    tab.addEventListener('click', (e) => {
        const tablist = tab.parentElement.children
        for (let i = 0; i < tablist.length; i++) {
            if (tablist[i].id == e.target.id) {
                tablist[i].classList.add('active');
            }
            else {
                tablist[i].classList.remove('active');
            }
        }
        const container = tab.parentElement.parentElement.children
        for (let i = 1; i < container.length; i++) {
            if (container[i].classList.contains(e.target.id)) {
                container[i].style.display = "block";
            }
            else {
                container[i].style.display = "none";
            }
        }
    })
})
Do not follow this link