메뉴나 토글형식의 ui에서 자주쓰는 스크립트 //기본 누르면 열렸다 펼쳤다 하도록 설정 // Optional: Automatically close other tabs when one is opened document.querySelectorAll('.tab-toggle').forEach(toggle => { toggle.addEventListener('change', function () { if (this.checked) { document.querySelectorAll('.tab-toggle').forEach(otherToggle => { if (otherToggle !== this) otherToggle.checked = false; }); } }); }); // 첫 번째 탭은 항상 열려 있고, 다른 탭은 하나만 열리도록 설정 document.addEventListener('DOMContentLoaded', () => { const tabToggles = document.querySelectorAll('.tab-toggle'); // 첫 번째 탭을 항상 체크된 상태로 설정하고 비활성화 if (tabToggles.length > 0) { tabToggles[0].checked = true; tabToggles[0].disabled = true; } tabToggles.forEach((toggle, index) => { if (index === 0) return; // 첫 번째 탭은 이벤트 리스너를 추가하지 않...