<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById('txt').value=c;
if(c == 100) return;
c=c+1;
t=setTimeout("timedCount()",30);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
</script>
</head>
<body onload="doTimer()">
<form>
<input type="button" value="Start count!">
<input type="text" id="txt">
</form>
<p>Click on the button above. The input field will count forever, starting at 0.</p>
</body>
</html>
Я хочу изменить
<input type="text" id="txt">
на
<div type="text" id="txt">
Это не работает.Я думаю, что проблема в
document.getElementById('txt').value=c;
Но я попытался
document.getElementById('txt').innerHTML=c;
Это все еще не работает.Может кто-нибудь сказать мне, почему?Ура !!!