簡體   English   中英

我如何才能獲取要“切換”的列表元素(JQuery),然后在完成動畫刪除()后,只需單擊鼠標中的img <li> ?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM