Ask coding questions

← Back to all posts
Removing Buttons
FallenAngel6 (31)

I have a question, how do you remove a button in HTML 5 (after you win the game). I'm planning on sharing this later so yeah...

Answered by xxpertHacker (930) [earned 5 cycles]
View Answer
EpicGamer007 (1736)

give the button an id then after its done, in your js add document.getElementById("button-with-id").remove();

xxpertHacker (930)

@EpicGamer007 It doesn't need an ID, but .remove() is the important part.

xxpertHacker (930)

Wait, EpicGamer007 answered the question though, not me!

FallenAngel6 (31)

@xxpertHacker You gave the better response

xxpertHacker (930)

@FallenAngel6 Well, if you think so, it's your choice.

LukeWright (286)

I ascended, but the crystal heart button doesn't work

FallenAngel6 (31)

@LukeWright I haven't coded that part yet

notGilbert (121)

If you want to reshow the button after removing it, use css display: none

const button = document.querySelector('...');

// hide it = 'none';

// show it = 'unset';