0

私はjQuery関数で作業を行っています。マウスオーバーイベントがトリガーされている間に機能する関数が1つありますが、私の要件は、マウスのホバリング中に呼び出すべきではなく、5秒ごとに呼び出す必要がありますが、これを達成できませんでした。その問題を解決するにはどうすればよいですか?

参考のためにスニペットを追加しました..

f.children(a.childSelector).each(function(h) {
        jQuery(this).mouseover(function(i) {
                var j = (a.reflect === true) ? 360 - (g * h) : g * h;
            j = jQuery.roundabout_toFloat(j);
            if (!jQuery.roundabout_isInFocus(f, j)) {
                i.preventDefault();
                if (f.data("roundabout").animating === 0) {
                    f.roundabout_animateAngleToFocus(j)
                }
                return false
            }
        })  
})
4

3 に答える 3

0

jQuery-Timersを見てください:http://archive.plugins.jquery.com/project/timers

$(document).everyTime(1000, "tag", function(i) { // every 1000ms
   // do something
}, 200); // 200 times
于 2012-08-28T21:09:33.467 に答える
0
var repeatFunction = setInterval(function(){
    //do something here
}, 5000); //repeats after interval of 5 second (atleast)
于 2012-08-28T06:33:34.397 に答える
0

5秒ごとに呼び出す必要があります

または を使用setInterval(..)して、より柔軟に機能を模倣しますsetTimeout(..)

何かのようなもの:

f.children(a.childSelector).each(function(h) {
        setInterval(function() {
            var j = (a.reflect === true) ? 360 - (g * h) : g * h;
            j = jQuery.roundabout_toFloat(j);
            if (!jQuery.roundabout_isInFocus(f, j)) {
                if (f.data("roundabout").animating === 0) {
                    f.roundabout_animateAngleToFocus(j)
                }
            }
        },5000);  
    })
于 2012-08-28T06:34:06.720 に答える