问问题
295 次
2 回答
2
.next()
will try to fetch only the next element if it satisfies the given selector, in your second case the next sibling is not the showDescription
element
$('.more').click(function () {
$(this).html(function (_, html) {
return $.trim(html) == '▼' ? '▲' : '▼'
}).nextAll('.showDescription').first().stop().fadeToggle();
});
Demo: Fiddle
于 2013-11-06T16:07:03.747 回答
1
.next
will only look at the one directly next, it won't look at all ones next. You want .nextUntil
.
$('.more').click(function() {
$(this).html($(this).html()=='▼'?'▲':'▼').nextUntil('.more', '.showDescription').stop().fadeToggle();
});
于 2013-11-06T16:10:42.297 回答