这样使用,后面的4000无效
setTimeout(removeGift(customer_id,gift_id),4000);function removeGift(customer_id,gift_id) {var x = 100;var y = 900;var rand = parseInt(Math.random() * (x - y + 1) + y); // 随机的位置$("#gift_"+customer_id+"_"+gift_id).animate({bottom:900,opacity:"0",left: 1000,},1000,'',function () {$("#gift_"+customer_id+"_"+gift_id).remove();});
}
这样使用,后面的4000秒有效
setTimeout(removeGift(customer_id,gift_id),4000);function removeGift(customer_id,gift_id) {return function(){var x = 100;var y = 900;var rand = parseInt(Math.random() * (x - y + 1) + y); // 随机的位置$("#gift_"+customer_id+"_"+gift_id).animate({bottom:900,opacity:"0",left: 1000,},1000,'',function () {$("#gift_"+customer_id+"_"+gift_id).remove();});}
}
通过return function,就有效果。很奇怪!