내가 dt
요소 중 하나에 배치되어있는 동안 다음 요소 인 dt
요소로 이동하려고합니다. 이것을 어떻게 할 수 있습니까?dom 트리에서 다음으로 이동하는 형제를 찾는 방법
<dl class="accordion">
<dt>Select Category</dt>
<dd></dd>
<dt>select product</dt>
<dd></dd>
</dl>
(function($) {
var allPanels = $('.accordion > dd').hide();
$('.accordion > dd:first-of-type').show();
$('.accordion > dt:first-of-type').addClass('accordion-active');
jQuery('.accordion > dt').on('click', function() {
$this = $(this);
$target = $this.next();
if (!$this.hasClass('accordion-active')) {
$this.parent().children('dd').slideUp();
jQuery('.accordion > dt').removeClass('accordion-active');
$this.addClass('accordion-active');
$target.addClass('active').slideDown();
}
return false;
});
})(jQuery);
thisdt은 무엇인가라는 질문의 코드에서
는,이 다음 업데이트를 제공합니다? –
그것은 작동하지 않습니다 ... $ this.next ("dt")는 어떻게 든 클릭 된 동일한 요소를 가리 킵니다 ... dom의 다음 dt 요소를 원합니다 –
'$ target = $ this.nextAll ('dt') .eq (0);'?! –