我在這裏需要的是雖然位於其中一個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 –
'$ target = $ this.nextAll('dt')的下一個dt元素.EQ(0);'? –