how to call javascript function automatically after some time
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var file = ["a","b","c","d"];
var myTimer;
var j = 0;
myTimer = setInterval(function() {
alert('hi');
j++;
for(var i = 0; i < 5; i++)
{
alert('i= '+i);
}
alert(j+'and'+file[j]);
if(file[j] == 'c'){
clearInterval( myTimer );
}
}, 1000);
}
</script>
</body>
</html>
Comments
Post a Comment