I am attaching my code below here for the use of setInterval() function of Javascript. The code runs only one time afer that it is not running docoment.write to write the value of i in the browser. Could anyone pls let me know at which place I am wrong with my code :
<html>
<head>
<script type="text/javascript">
function inCreas(){
var i = 0;
var interval = setInterval(func,2000);
function func(){i++;
document.write("<p>This is the value of i : "+ i +"</p>");
}
}
</script>
</head>
<body onload="inCreas()">
</body>
</html>
I have tried it in IE 8 and Firefox 24.0, but result is same.
Thanks in advance. Vasudev
document.writeafter the document has finished loading. Select the element you want to add the content to and either create the new DOM node(s) and append them or append the extra HTML string to itsinnerHTMLproperty.