SetInterval is a very useful JS function that can be used to repeatedly perform certain functions. Using this we can implement some very interesting features, such as:
Without refreshing the page, "real -time" gets greetings given to you by other members, and pops up to display display and other
Let's give a sample code: (There are some jQuery methods)
Copy code code as follows:
<html>
<head>
<Title> Jquery Operation Select </Title>
<script type = "text/javascript" src = "jquery-1.2.6.pack.js"> </script>
<script type = "text/javascript">
var I = 1;
var _interval;
Function Showtime ()
{{
var today = new date ();
$ ("#msg"). html (today.tolocalestring () + ", i =" + i);
i ++;
if (i> 10)
{{
Clearinterval (_INTERVAL);
}
}
$ (docume) .Ready (function () {{) {
$ ("#btnstart").
showtime ();
_INTERVAL = SETINTERVAL ("Showtime ()", 1000); 1000);
})
$ ("#btnstop").
Clearinterval (_INTERVAL);
i = 0;
})
})
</script>
</head>
<body>
<laabel id = "msg"> </label>
<button id = "btnstart"> Start time </Button>
<button id = "btnstop"> Stop
<script type = "text/javascript"> </script>
</body>
</html>