Wednesday 26 February 2014

Simple Timer in Java Script




0



Here is code, hope you enjoyed.
This is simples Javascript code you ever seen for a timer.


<html>
<head><title></title>
<script>
function ctime()
{
var int = setInterval(function(){updateField();},1000);
}


function updateField()
{
var t = document.getElementById('timer').innerHTML;
var inc= (parseInt(t)+1);
document.getElementById("timer").innerHTML=inc;
</script>
</head>
<body>
<div id="bt_timer" style="float: right;">
<button onclick="ctime();" style="float: right;" type="button">Timer</button><br />
<div id="timer">0</div>
</div>
</body>
</html>

No comments:

Post a Comment