Hide html elements after a key is pressed in javascript

henhen

I was wondering if there was a way to hide header tags, images, divs etc from showing on an html page after a certain key is pressed. I am making a hangman game and when the player loses or wins, I display a message with a header tag. If the user presses Y, the game restarts but I dont how to make the header tag that ask "play again" to disappear once the player chooses Y

Asifuzzaman Redoy

Hey there are several methods for doing this I am just showing here a keypress example for Enter button click lets try the below code

$(document).keypress(function(e) {
  if(e.which == 13) {    //for enter button
    $('#div_name').hide();
}
 });

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related