2 に答える
2
.next()
指定されたセレクターを満たす場合、次の要素のみをフェッチしようとします。2番目のケースでは、次の兄弟はshowDescription
要素ではありません
$('.more').click(function () {
$(this).html(function (_, html) {
return $.trim(html) == '▼' ? '▲' : '▼'
}).nextAll('.showDescription').first().stop().fadeToggle();
});
デモ:フィドル
于 2013-11-06T16:07:03.747 に答える
1
.next
は、すぐ隣のものだけを調べます。次にすべてのものを調べるわけではありません。あなたがしたい.nextUntil
。
$('.more').click(function() {
$(this).html($(this).html()=='▼'?'▲':'▼').nextUntil('.more', '.showDescription').stop().fadeToggle();
});
于 2013-11-06T16:10:42.297 に答える