jQuery首先悬停,然后悬停
当我将鼠标悬停在jQuery首先悬停,然后悬停,jquery,Jquery,当我将鼠标悬停在第一个上时,它将显示第二个 如果然后将鼠标悬停到Second,Second将保持显示,否则隐藏Second 我的问题是在悬停第一个和悬停第二个之间,隐藏第二个太快了 如何延迟$(“.second”).hide(“slow”)在我悬停到第二个之前 $(".first").hover( function(){ $(".second").show(); }, function(){ $(".second").hide("slow" )
第一个
上时,它将显示第二个
如果然后将鼠标悬停到Second
,Second
将保持显示,否则隐藏Second
我的问题是在悬停第一个
和悬停第二个
之间,隐藏第二个
太快了
如何延迟$(“.second”).hide(“slow”)代码>在我悬停到第二个之前
$(".first").hover(
function(){
$(".second").show();
},
function(){
$(".second").hide("slow" );
}
);
$(".second").hover(
function(){
$(".second").show();
},
function(){
$(".second").hide("slow" );
}
);
解决方案是使用setTimeout()
演示:解决方案是使用setTimeout()
演示:解决方案是使用setTimeout()
演示:解决方案是使用setTimeout()
演示:
var $second = $(".second");
$(".first").hover(function () {
clearTimeout($second.data('timer'));
$second.stop(true, true).show();
}, function () {
var timer = setTimeout(function () {
$second.stop(true, true).hide("slow");
}, 200);
$second.data('timer', timer);
});
$(".second").hover(function () {
clearTimeout($second.data('timer'))
$second.stop(true, true).show();
}, function () {
$second.stop(true, true).hide("slow");
});
$( "#clickme" ).click(function() {
$( "#book" ).hide( "slow", function() {
alert( "Animation complete." );
});
});