<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>1 second counter</title>
<style type="text/css">
input {
border: 0;
font: inherit;
}
</style>
<script type="text/javascript">
function plusOne() {
// If using an input element value...
var inputEl = document.getElementById('inputEl');
inputEl.value = parseInt(inputEl.value) + 1;
// If using the content ('childNode') of an id element...
var spanEl = document.getElementById('spanEl');
spanEl.childNodes[0].nodeValue = ( parseInt(spanEl.childNodes[0].nodeValue) + 1 );
}
var stop = setInterval("plusOne()",1000);
window.onload = plusOne;
</script>
</head>
<body>
<p>Counter: <input value="0" id="inputEl" type="text" size="7" readonly="readonly" /></p>
<p>Counter: <span id="spanEl">0</span></p>
</body>
</html>
Detta bör fungera!