<div class="vtabs-wrapper blush-cards">
<div class="vtabs-cont">
<div class="vtab-buttons">
<button class="vtab-btn">Вкладка 1</button>
<button class="vtab-btn">Вкладка 2</button>
<button class="vtab-btn">Вкладка 3</button>
<button class="vtab-btn">Вкладка 4</button>
</div>
<div class="vtab-content">Содержимое 1</div>
<div class="vtab-content">Содержимое 2</div>
<div class="vtab-content">Содержимое 3</div>
<div class="vtab-content">Содержимое4</div>
</div>
</div>
<!-- вкладки для ЛС без ID by Vandra --> <script> function initTabs(modal) { modal.querySelectorAll(".vtabs-cont").forEach(tabContainer => { const buttons = tabContainer.querySelectorAll(".vtab-btn"); const tabs = tabContainer.querySelectorAll(".vtab-content"); if (!buttons.length || !tabs.length) return; if (tabContainer.dataset.tabsInitialized === "true") return; tabContainer.dataset.tabsInitialized = "true"; function switchTab(index) { tabs.forEach(tab => tab.classList.remove("active")); buttons.forEach(btn => btn.classList.remove("active")); tabs[index].classList.add("active"); buttons[index].classList.add("active"); } buttons.forEach((button, index) => { button.addEventListener("click", () => switchTab(index)); }); switchTab(0); }); } const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType === 1 && node.classList.contains(".vtabs-wrapper")) { initTabs(node); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); document.addEventListener("DOMContentLoaded", () => { document.querySelectorAll(".vtabs-wrapper").forEach(initTabs); }); </script>
ВЕРСИЯ 2 (другие узлы)
<!-- текстовые поля вместо строк для ввода в профиле by Vandra --> <script> document.addEventListener("DOMContentLoaded", function () { const profileContainer = document.getElementById("profile8"); if (!profileContainer) return; const profInputs = profileContainer.querySelectorAll("#fld2, #fld3, #fld4, #fld5"); profInputs.forEach(profInput => { const profTextarea = document.createElement("textarea"); for (let { name, value } of profInput.attributes) { profTextarea.setAttribute(name, value); } profTextarea.value = profInput.value; profInput.replaceWith(profTextarea); }); }); </script> <!-- вкладки для ЛС без ID by Vandra --> <script> function initTabs(container) { container.querySelectorAll(".vtabs-cont").forEach(tabContainer => { const buttons = tabContainer.querySelectorAll(".vtab-btn"); const tabs = tabContainer.querySelectorAll(".vtab-content"); if (!buttons.length || !tabs.length) return; if (tabContainer.dataset.tabsInitialized === "true") return; tabContainer.dataset.tabsInitialized = "true"; function switchTab(index) { tabs.forEach(tab => tab.classList.remove("active")); buttons.forEach(btn => btn.classList.remove("active")); tabs[index].classList.add("active"); buttons[index].classList.add("active"); } buttons.forEach((button, index) => { button.addEventListener("click", () => switchTab(index)); }); switchTab(0); }); } const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType !== 1) return; if (node.classList && node.classList.contains("vtabs-wrapper")) { initTabs(node); } const nestedWrappers = node.querySelectorAll?.(".vtabs-wrapper"); nestedWrappers?.forEach(wrapper => { initTabs(wrapper); }); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); document.querySelectorAll(".vtabs-wrapper").forEach(initTabs); </script>
.vtab-content { display: none; padding: 10px; border: 1px solid #ccc; } .vtab-content.active { display: block; } .vtab-btn { padding: 5px 10px; margin-right: 5px; cursor: pointer; background: #eee; border: 1px solid #bbb; transition: background 0.3s; } .vtab-btn.active { background: #ccc; font-weight: bold; }