我有这段代码,但它只执行一次...
$('.' + container).hover(function() {
t = setTimeout( function(elem){
//this should be executed as long as I hover,
//with interval declared in viewSpped variable
$(elem).find('img').first().appendTo('.' + container).fadeOut(500);
$(elem).find('img').first().fadeIn(800);
}(this), viewSpeed);
}...知道我做错了什么吗?谢谢!
发布于 2012-09-29 23:24:06
您将立即调用该函数,而不是将其用作回调(这无论如何都不会起作用,因为您需要传递一个参数),我想您的意思也是setInterval。
var elem = $(this);
var container = $('.' + container);
t = setInterval(function() {
elem.find('img').first().appendTo(container).fadeOut(500);
elem.find('img').first().fadeIn(800);
}, viewSpeed);https://stackoverflow.com/questions/12653948
复制相似问题