Шаблон:Tabs JS

 

   ,  
<script>var pageTab = function() {
var pageMenu = document.querySelector('.wf-tabs-menu'),
pageTabs = document.querySelectorAll('.wf-tabs-list__item'),
pageTabContent = document.querySelectorAll('.tab-content'),
pageTabTarget;
pageTabs.forEach(function(item) {
item.addEventListener('click', selectPageTabs);
});
function selectPageTabs() {
pageTabs.forEach(function(item) {
item.classList.remove('type-opened');
});
this.classList.add('type-opened');
pageTabTarget = this.getAttribute('data-tab-target');
selectPageTabContent(pageTabTarget);
};
function selectPageTabContent() {
pageTabContent.forEach(function(item) {
item.classList.contains(pageTabTarget) ? item.classList.add('type-opened') : item.classList.remove('type-opened');
});
};
pageMenu.addEventListener('click', selectPageMenu);
function selectPageMenu() {
if (document.documentElement.clientWidth <= 768) {
pageMenu.classList.toggle('type-opened');
};
};
};
pageTab();
</script>
 
Профиль