开发者

how to setInterval on mouseout jquery? [closed]

开发者 https://www.devze.com 2023-02-21 04:50 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

setInterval on mouseout dont work can any help me please here is my code

<script type="text/javascript">
$(document).ready(function() {
$("#time").load("ajaxTime.php");

var refreshId = setInterval(function() {
$("#time").load('ajaxTime.php?randval='+ Math.random());
}, 1000);
 $('#stop').mouseover(function(){
    clearInterval(refreshId);
 });
  $('#stop').mouseout(function(){
    setInterval(refrashID, 1000);
 });
});

   </script>
        <center>
            <div id="stop" style="width:100px; height: 100px; border: 1px solid #000;">
                <div id="time"></d开发者_如何学Goiv>
            </div>
        </center>


First, you wrote refrashID instead of refreshId. But you need to assign that function you want as a variable so you can reuse it:

var $interval_function = function() { $("#time").load('ajaxTime.php?randval='+ Math.random()); };

// then when you set the interval:
refreshId = setInterval($interval_function, 1000);

// clear the interval:
clearInterval(refreshId)

// and you have to store the new result from setInterval if you run it again:
refreshId = setInterval($interval_function, 1000);
0

精彩评论

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

关注公众号