Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
600 views
Welcome To Ask or Share your Answers For Others

1 Answer

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);
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...