Ich habe es schon einmal versucht, aber es funktioniert nicht. Ist es irgendein Unrecht des Codes?Javascript - Wie programmiere ich einen Klickzähler?
<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 (" Zählen ") .value = ++ x;' wäre auch eine nette einzige Zeile. –
Ich wollte es so nah an seinem ursprünglichen Code halten. Ein schöner Liner. – barkmadley