[英]How can I get a list element to be “toggled” (JQuery) and then when this animation is done removed(), all upon a mouse click of the img in the <li>?
As it stands the remove function doesn't work. 就目前而言,删除功能不起作用。 Any suggestions? 有什么建议么?
var toggle = new function() {
$(document).on('click', 'img', function () {
$(this).parent().toggle('slide');
})
}
var remove = new function() {
$(document).on('click', 'img',
setTimeout(function () {
$(this).parent().remove();
}, 1000);
)
}
The function your are looking for is .queue()
. 您正在寻找的功能是.queue()
。 It will execute a provided callback after the previous animation has finished: 上一个动画完成后,它将执行提供的回调:
$(document).on('click', 'img', function() {
var $entry = $(this).parent();
$entry.toggle('slide').queue(function(next) {
$entry.remove();
next();
});
});
Working example: http://jsfiddle.net/rbBgS/ 工作示例: http : //jsfiddle.net/rbBgS/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.