OnMouseOver暂停或停止setTimeOut函数

时间:2013-01-30 12:10:23

标签: javascript

嗨我这里有twitter bootstrap提醒,其中我实现了持续时间/延迟,1秒后它就消失了......

但我想要完成的是当我将鼠标悬停在闪光警报时,setTimeOut会暂停一段时间或停止。

这是我的js文件:

var hideFlashes;

$(document).ready(function() {
  return setTimeout(hideFlashes, 1000);
});

hideFlashes = function() {
  return $(".alert").fadeOut(4000);
};

我正在调用div类`alert

<div class="alert alert-info" id="info">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <p><strong>Oppcis Tips:</strong>
        You have the privileges to view, add, edit or delete specific agencies.
        </p>
    </div>

我真的想知道如何stop某个衰落的计时器。

任何变通办法都将受到赞赏。

2 个答案:

答案 0 :(得分:0)

尝试这样的事情:

$(".alert").hover(function(){$(".alert").stop();}); 

答案 1 :(得分:0)

仍然感谢^ @drasick的上述方法..

分享我的要点:https://gist.github.com/4672970

对于那些希望采用与我相同方法的人。

我使用了mouseentermouseleave函数

代替mouseovermouseouthover

https://gist.github.com/4672970

相关问题