javascript hiding/showing div

Associate
Joined
11 Oct 2008
Posts
268
I am using the following code to display a hidden div (pause) on click.
At the moment it shows the div on click.
I have been trying to use classList.remove in the else block to then hide the div again but its removing the class from the body tag.

Any ideas what I've done wrong? Thanks
Code:
  document.getElementsByClassName('pause-game')[0].addEventListener('click', function () {
              document.body.classList.add('pause');
                
                isPaused = !isPaused;
                if (isPaused) this.innerHTML = "Resume";
                  
                else this.innerHTML = "Pause";
 })
 
Back
Top Bottom