我有这段代码,用于在我正在工作的网站上滑动打开篮子预览。如果用户悬停在上面,它会保持打开状态,但是我希望在我的悬停回调触发之前有两秒的延迟。这只是为了防止用户不想让鼠标离开篮子区域。
下面是我用来动画显示篮子的代码:
$('.cart_button, .cart_module').hover(function(){
$(".cart_module").stop().animate({top:'39px'},{duration:500});
}, function(){
$('.cart_module').stop().animate({top: -cartHeight},{duration:500})
});
以下是我尝试使用的代码,但没有效果:
$('.cart_button, .cart_module').hover(function(){
$(".cart_module").delay().animate({top:'39px'},{duration:500});
}, function(){
$('.cart_module').delay().animate({top: -cartHeight},{duration:500})
});