Untitled
unknown
plain_text
a year ago
625 B
3
Indexable
const tabBar = new mdc.tabBar.MDCTabBar(document.querySelector('.mdc-tab-bar')); tabBar.listen('MDCTabBar:activated', (event) => { // Lấy ra các phần tử content của tab để hiển thị/ẩn const tabContents = document.querySelectorAll('.tab-content'); // Ẩn tất cả các tab content tabContents.forEach((content) => { content.classList.remove('active'); }); // Hiển thị tab content của tab được kích hoạt const activatedContent = document.querySelector(.tab-content[data-tab="${event.detail.index}"]); activatedContent.classList.add('active'); });
Editor is loading...
Leave a Comment