How to fire jQuery events with setTimeout?
Answers
Answered by
0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>The JavaScript setInterval() Method</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
var myVar;
function showTime(){
var d = new Date();
var t = d.toLocaleTimeString();
$("#demo").html(t);
function stopFunction(){
clearInterval(myVar);
}
$(document).ready(function(){
myVar = setInterval("showTime()", 1000);
});
</script>
</head>
<body>
<p id="demo"></p>
<button onclick = "stopFunction()">Stop Timer</button>
</body>
</html>
Similar questions
Math,
6 months ago
Science,
6 months ago
Social Sciences,
1 year ago
English,
1 year ago
Geography,
1 year ago