Reputation: 107
I am trying to make a simple game about sliding ice-blocks. However, I tested this JSFiddle and I want to "hide" the image/button on the line alert('Game starts!');
. I tried startButton.style = "visibility: hidden;";
but it didn't work...
I only need to resolve this problem, I know how to code the game itself :)
Upvotes: 0
Views: 76
Reputation: 20521
startButton.onclick = function()
{
startButton.style.visibility="hidden";
/* OR
startButton.style.display="none";
*/
alert('Game starts!');
}
Upvotes: 0
Reputation: 1538
You can also use jQuery UI, which has a "hide" method. You can then simply say
$('.startButton').hide()
You can even apply different effects.
However, this will set the visibility to none, removing the object from the DOM. If you don't care about that, it's fine, but it should be borne in mind.
Upvotes: 0
Reputation: 990
Adding this after the alert seems to work.
this.style.display = 'none';
Upvotes: 2
Reputation: 2812
try
document.getElementById("startButton").style.visibility = 'hidden';
HTMLElement.style reference (MDN)
Upvotes: 0