0
나는 클릭 (click)시 확장 가능한 세 개의 섹션이 있는데, 잘 작동합니다. 그러나 확장 된 섹션 내에서 열린 섹션을 닫아야하는 버튼이 있지만 첫 번째 섹션의 닫기 버튼 만 실제로 섹션을 닫습니다. 두 번째 및 세 번째 섹션의 닫기 버튼은 타겟팅하는 모든 클래스와 ID가 동일해도 종료되지 않습니다.JQuery 확장 섹션
HTML
<div id="first-section">
<a id="first-section-link"></a>
</div>
<div id="second-section">
<a id="second-section-link"></a>
</div>
<div id="third-section">
<a id="third-section-link"></a>
</div>
<div id="first-expanded" class="expanded-section">
<a id="closeBtn"></a>
</div>
<div id="second-expanded" class="expanded-section">
<a id="closeBtn"></a>
</div>
<div id="third-expanded" class="expanded-section">
<a id="closeBtn"></a>
</div>
JQuery와
$('#closeBtn').on('click', function() {
$('.expanded-section').slideUp(350);
});
$('#first-section-link').on('click', function() {
$('#first-expanded').delay(350).slideDown(350);
});
$('#second-section-link').on('click', function() {
$('#second-expanded').delay(350).slideDown(350);
});
$('#third-section-link').on('click', function() {
$('#third-expanded').delay(350).slideDown(350);
});
잘못된 HTML이 있습니다. id의 값은 전체 HTML 문서에서 고유해야합니다. –