Issues with setTimeout() inside jQuery .each

后端 未结 5 767
猫巷女王i
猫巷女王i 2021-01-21 06:33

The following code will not work properly. I\'ve tried different variations & searching everywhere but no luck.

i = 1;
var timer = new Array();
jQuery(\'a\')         


        
5条回答
  •  [愿得一人]
    2021-01-21 07:01

    Wrap remove element with a function

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

提交回复
热议问题