jQuery .each中setTimeout()的问题

Fra*_*Kim 3 each jquery settimeout

以下代码无法正常运行.我尝试了不同的变化和搜索,但没有运气.

i = 1;
var timer = new Array();
jQuery('a').each(function($) {
    i++;
    timer[i] = setTimeout(jQuery(this).remove(), i * 5000)
})
Run Code Online (Sandbox Code Playgroud)

小智 8

用函数包裹删除元素

i = 1;
var timer = new Array();
jQuery('a').each(function($) {
    i++;
    var thiz = jQuery(this);
    timer[i] = setTimeout(function() { thiz.remove(); }, i * 5000);
})
Run Code Online (Sandbox Code Playgroud)