javascript - Continuous mouseover - Stack Overflow

I am looking for a way to repeat a mouseover action until the user moves away from the target.A mouse

I am looking for a way to repeat a mouseover action until the user moves away from the target. A mouseover invokes a function once, I am looking for a way to keep doing the function.

Cheers, Gazler.

I am looking for a way to repeat a mouseover action until the user moves away from the target. A mouseover invokes a function once, I am looking for a way to keep doing the function.

Cheers, Gazler.

Share Improve this question edited Aug 26, 2013 at 9:46 Daniel Daranas 22.6k9 gold badges65 silver badges121 bronze badges asked Dec 13, 2009 at 20:50 GazlerGazler 84.2k18 gold badges284 silver badges245 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

You'll need to use setInterval():

var to;
var doStuff = function() {
    console.log('doing stuff...');
};

$('a').hover(function(e) {
    to = window.setInterval(doStuff, 1);
},function(e) {
    window.clearInterval(to);
})
//continuous


var timer;

var doStuff=function(quit){

  console.log('doing stuff');

  if (quit!==true){

    timer=setTimeout(doStuff, 100);

  }

  else{

    clearTimeout(timer);

  }

};

$('div#continuous').bind('mouseenter', doStuff).bind('mouseleave', function(){doStuff(true);});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744253437a4565278.html

相关推荐

  • javascript - Continuous mouseover - Stack Overflow

    I am looking for a way to repeat a mouseover action until the user moves away from the target.A mouse

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信