Created
October 26, 2015 09:42
-
-
Save JuanjoSalvador/0545c414059d318b442b to your computer and use it in GitHub Desktop.
Cronometro en JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Cronómetro</title> | |
<meta charset="utf-8"> | |
<script> | |
var cronos; | |
var tiempo; | |
function init() { | |
cronos = setInterval(function() { timer() }, 1000); | |
} | |
function timer() { | |
tiempo = parseInt(document.getElementById('time').value); | |
document.getElementById('time').value = eval(tiempo + 1); | |
} | |
function reset() { | |
tiempo = parseInt(document.getElementById('time').value); | |
document.getElementById('time').value = "0"; | |
} | |
function stop() { | |
clearInterval(cronos); | |
} | |
</script> | |
</head> | |
<body> | |
<input type="button" value="Empezar" onclick="init()" /> | |
<input type="button" value="Reiniciar" onclick="reset()" /> | |
<input type="button" value="Parar" onclick="stop()" /> | |
<input id="time" name="time" value="0" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment