set/clear interval issue

Posted by 3gwebtrain on Stack Overflow See other posts from Stack Overflow or by 3gwebtrain
Published on 2010-04-27T09:36:18Z Indexed on 2010/04/27 9:43 UTC
Read the original article Hit count: 248

Filed under:
|
|

HI,

i am using the following code to show a link which is inside the li element. the constrain is, once the mouse enter into li element, and if it's stay inside 3sec, then it need to show. once i leave from li element, immateriality it should hide. for this, i am using :

var showTimeOut; var thisElement

$('.user-list li').live('mouseover',function(){

    thisElement = $(this).children('a.copier-link');

    showTimeOut = setInterval(function(){
        thisElement.css({'display':'block'});
    },3000);
})

$('.user-list li').live('mouseleave',function(){
    clearInterval(showTimeOut);
    thisElement.hide();
})

It's work fine. But the problem is, while i cross the li element with just a second, even the interval is calling, and showing the link. but i need to show only, if i stay inside 3sec and it need to hide there after, again i stay back 3sec.

anything wrong with my code?, else any one give me the best suggestion?

Thanks.

© Stack Overflow or respective owner

Related posts about setinterval

Related posts about JavaScript