我想在动画结束后隐藏潜水。这可能吗?
我可以在这里向您展示代码
$(document).ready(function() {
$('button').click(function() {
var $lefty = $(this).next();
$lefty.animate({
left: parseInt($lefty.css('left'),10) == 0 ?
-$lefty.outerWidth() :
0
});
});
});
<强> Demo
最佳答案
将回调传递给 animate
作为第二个参数。此外,您需要将 .next()
更改为其他内容以仅查找第一个子项,并且还可以进行一些其他优化。你的CSS也错了。 Here's the updated jsFiddle.
$(document).ready(function() {
$('button').click(function() {
var $lefty = $(this).next().children().eq(0);
$lefty.animate({
left: -$lefty.outerWidth()
}, function() {
$lefty.next().show();
$lefty.remove();
});
});
});
关于javascript - jQuery : how to hide div after animation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9977865/