javascript - Run jQuery slideDown complete function only after last item has completed -
this question has answer here:
i understand can pass function slideup/slidedown run once transition has completed:
$('li').slideup({ complete: function(){ alert('done'); } });
with html alert shown 3 times.
<ul> <li>[content here]</li> <li>[content here]</li> <li>[content here]</li> </ul>
is there way have complete
function fire once, when last list item has completed slideup? (fiddle)
you can "redo" selector , check if this
last :
$('li').slideup({ complete: function(){ if($('li:last').is(this)){ alert('done'); } } });
fiddle : http://jsfiddle.net/5nqsu/
caching selector better :
var $li = $('li'); $li.slideup({ complete: function(){ if($li.last().is(this)){ alert('done'); } } });
Comments
Post a Comment