Javascript jQuery实时鼠标指针延迟
我想在mouseenter事件上调用匿名函数之前延迟2秒。这里的代码工作得很好,但我想延迟初始动画或悬停2秒,似乎无法理解它Javascript jQuery实时鼠标指针延迟,javascript,jquery,animation,delay,Javascript,Jquery,Animation,Delay,我想在mouseenter事件上调用匿名函数之前延迟2秒。这里的代码工作得很好,但我想延迟初始动画或悬停2秒,似乎无法理解它 $('div#response div.results').live({ mouseenter: function() { $(this).find('.zoomer').stop('true').css({ 'z-index': '999' }).animate({ "overfl
$('div#response div.results').live({
mouseenter: function() {
$(this).find('.zoomer').stop('true').css({
'z-index': '999'
}).animate({
"overflow": 'visible',
backgroundColor: '#fff',
'width': '274px'
}, {
duration: 100,
easing: 'easeOutExpo',
queue: false
});
$(this).find('img').stop('true').animate({
"height": "180px",
"width": "270px"
}, {
duration: 1,
easing: 'linear',
queue: false
});
},
mouseleave: function() {
$(this).find('.zoomer').stop('true').animate({
"overflow": 'visible',
backgroundColor: '#f7f7f7',
'width': '164px'
}, {
duration: 10,
easing: 'linear',
queue: false
});
$(this).find('img').stop('true').animate({
"height": "108px",
"width": "162px"
}, {
duration: 1,
easing: 'easeOutCirc',
queue: false
})
}
});
使用延迟功能?这应该可以:p可能需要对声明
var$this=$(this)
进行校正,并在当前代码中使用该功能,而当前代码中有$(this)
仍然不起作用。。如果我只是把警报(‘测试’)放进去就行了;但是如果我在setTimeoutvar$this=$(this)
之前粘贴剩余的代码,并将所有内容替换为$(this)
到$this
,那么如果您也给我们相关的HTML,这会有所帮助。
mouseenter:
function()
{
setTimeout(function(){
//your code
}, 2000);
}
$(this).find('.zoomer')...delay(2000).animate(...