I have a button which is enabled at the beginning, but I want to disable it. I need it for a game. If the player chooses to play more, the game starts again, if not, the button "Click on me" should be disabled. Thank you in advance!
Here is my code:
var y;
function playAgain()
{
y=confirm("PLAY AGAIN?");
if(y==true)
{
alert("Let's play it again!");
location.reload(true);
}
else if(y==false)
{
alert("Thank you!\nSee you soon!");
document.getElementById("button").disabled="disabled";
//document.getElementById("button").disabled="true";
}
}
The HTML code:
<body>
<input type="button" value="Click on me" onClick="playAgain()" />
</body>
id="button"to your input button?