0
Button Clicker
How do I make it so my if statement doesn’t straight away go to ten? https://code.sololearn.com/WMCc8aOVtd0i/?ref=app
2 Antworten
0
Primary issue was the use of = (assignment operator) for testing <counter>, where == (equality operator) should've been used.
var counter = 0;
function button()
{
if( counter == 10 )
{
return false; // no more click allowed
}
counter++;
document.getElementById("counter").innerHTML = counter;
if (counter == 10)
{
alert("You Win");
}
}
0
<button onclick="/*Your JavaScript Codes*/">text</button>