[英]When toggling a class on a menu element. How can I make it so that class gets removed on previously toggled elements?
[英]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>?
就目前而言,刪除功能不起作用。 有什么建議么?
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);
)
}
您正在尋找的功能是.queue()
。 上一個動畫完成后,它將執行提供的回調:
$(document).on('click', 'img', function() {
var $entry = $(this).parent();
$entry.toggle('slide').queue(function(next) {
$entry.remove();
next();
});
});
工作示例: http : //jsfiddle.net/rbBgS/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.