开发者

can i use setInterval function twice in a .hover()?

can i use setInterval twice in .hover()? is yes how is it possible??

wht i have in .hover is::

  var target = evt.tar开发者_运维问答get; 

      if (target.timer) {
        clearTimeout(target.timer);
        target.timer = null;
      }
      target.timer =  setInterval(function() {  
                    $('.'+item).addClass(item+'-    over2');},
                    500,
                    function() {$('.'+item).removeClass(item+'-over2');},1000);$('.'+item).addClass(item+'-over1');

Now inside this hover, i need to set another time delay to remove both classes -over1 and -over2

How is this possible??

Any help is highly appreciable


You can use several setTimeout or setIntervall after each other, but each will return it's own handler so you need seperate variables to store them if you need to reference them.

But remember, setIntervall starts a repeating call to the method that will be called repeatedly every intervall.

So for hiding some popup you probably want setTimeout.

Alternative jQuery methods:

http://api.jquery.com/category/effects/

http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜