时间:2010-07-25 12:29:57

标签: javascript jquery hover delay

4 个答案:

答案 0 :(得分:25)

答案 1 :(得分:4)

我正在寻找类似问题的答案,我发现.animate()也可以用来处理这个问题,并且它服从.stop()

它看起来像这样:

$('.file a').live('mouseenter', function() {
    $('#download')
        .stop(true, true)
        .animate({opacity:0}, 1000);            // one second delay
        .animate({opacity:1}, 'fast', 'swing');
}).live('mouseleave', function() {
    $('#download')
        .stop(true, true)
        .animate({opacity:0}, 'slow', 'swing');
});

答案 2 :(得分:3)

答案 3 :(得分:0)

你可以在不使用延迟事件的情况下在jquery上使用它。

$('.file a').hover(function() {
  time = setTimeout(function() {
     $('#download').fadeIn();
  },1000);
},function(){
    clearTimeout(time);
});

1000是你在$('#download')之后淡出的时间。