미디어위키:Common.js: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
 
7번째 줄: 7번째 줄:
console.log("Common.js 불러옴!");
console.log("Common.js 불러옴!");


// 펼치기/접기 스크립트
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function() {
   document.querySelectorAll('.toggleBtn').forEach(function(btn) {
   var toggles = document.querySelectorAll(".toggleBtn");
     console.log('버튼 발견:', btn); // 추가
  toggles.forEach(function(toggle) {
    btn.addEventListener('click', function() {
     toggle.addEventListener("click", function() {
       var targetId = btn.getAttribute('data-target');
       var targetId = toggle.getAttribute("data-target");
      console.log('대상 ID:', targetId); // 추가
      if (!targetId) return;
       var target = document.getElementById(targetId);
       var target = document.getElementById(targetId);
      console.log('대상 객체:', target); // 추가
       if (!target) return;
       if (!target) return;
       if (target.style.display === 'none' || target.style.display === '') {
       if (target.style.display === "none" || target.style.display === "") {
         target.style.display = 'block';
         target.style.display = "block";
       } else {
       } else {
         target.style.display = 'none';
         target.style.display = "none";
       }
       }
     });
     });
   });
   });
});
});




/* DO NOT ADD CODE BELOW THIS LINE */
/* DO NOT ADD CODE BELOW THIS LINE */

2025년 4월 27일 (일) 17:19 기준 최신판

/**
 * 이 스크립트는 위키백과 전체에 적용됩니다. 고칠 때는 주의해주세요.
 * [[위키백과:위키프로젝트 시스템]] 참고
 *
 * 스크립트를 넣을 때는 충분한 설명, 출처를 넣어주세요! 이후 관리가 어려워집니다.
 **/
console.log("Common.js 불러옴!");

// 펼치기/접기 스크립트
document.addEventListener("DOMContentLoaded", function() {
  var toggles = document.querySelectorAll(".toggleBtn");
  toggles.forEach(function(toggle) {
    toggle.addEventListener("click", function() {
      var targetId = toggle.getAttribute("data-target");
      var target = document.getElementById(targetId);
      if (!target) return;
      if (target.style.display === "none" || target.style.display === "") {
        target.style.display = "block";
      } else {
        target.style.display = "none";
      }
    });
  });
});



/* DO NOT ADD CODE BELOW THIS LINE */