"틀:이미지스와이퍼"의 두 판 사이의 차이
광주문화예술인문스토리플랫폼
| 89번째 줄: | 89번째 줄: | ||
console.log('남은 슬라이드 개수:', remainingSlides.length); | console.log('남은 슬라이드 개수:', remainingSlides.length); | ||
| − | // 슬라이드가 하나도 없으면 스와이퍼 컨테이너 제거 | + | // 슬라이드가 하나도 없으면 스와이퍼 컨테이너 및 상위 h2 제거 |
if (remainingSlides.length === 0 ) { | if (remainingSlides.length === 0 ) { | ||
| − | + | if(swiperContainer){ | |
| − | console.log('슬라이드가 없어서 스와이퍼 컨테이너 제거'); | + | console.log('슬라이드가 없어서 스와이퍼 컨테이너 제거'); |
| − | |||
| − | |||
| + | // id가 "이미지"인 h2 찾기 | ||
| + | var imageHeading = document.querySelector('#이미지'); | ||
| + | if (imageHeading) { | ||
| + | // h2 요소의 부모 찾기 (일반적으로 h2.mw-headline의 부모) | ||
| + | var headingParent = imageHeading.closest('h2'); | ||
| + | if (headingParent) { | ||
| + | console.log('이미지 섹션 제목도 제거'); | ||
| + | headingParent.remove(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | swiperContainer.remove(); | ||
| + | } | ||
} | } | ||
}; | }; | ||