Computer Science, asked by aaryasuman3248, 1 year ago

How to fire jQuery events with setTimeout?

Answers

Answered by omegads04
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