我曾嘗試過,但它不起作用。代碼有錯嗎?Javascript - 如何編程點擊計數器?
<script type ="text/javascript">
function count()
{
var x = 0;
x += 1;
document.getElementById("counting").value = x;
}
</script>
</head>
<body>
<input type ="button" value = "Click" onclick = "count()"/><br><br>
<input id = "counting" type = "text" />
</body>
'document.getElementById(「counting」).value = ++ x;'也是一個不錯的單行。 – 2009-11-23 12:09:57
我想保持它接近他的原始代碼。很好的班輪。 – barkmadley 2009-11-23 12:11:01