0

Hello I have the following button and JS code:

<button type="button" id="play-pause" ><img id = "playbtn" src="img/icons/play.png"></button>
 playButton.addEventListener("click", function() {

              if (video.paused == true) {
                // Play the video
                video.play();

                // Update the button text to 'Pause'
                 document.getElementById("playbtn").src = "img/icons/pause.png";
              } else {
                // Pause the video
                video.pause();

                // Update the button text to 'Play'
                document.getElementById("playbtn").src = "img/icons/play.png";
              }
            });

When i click my button it changes the button to a play icon image and when i click it again it changes it to a pause icon button. This works fine but it still displays the default button background. I want it to be just an image. It currently gives my a button GUI with an image in it. Thats not what I want, how can I fix it?

0

2 Answers 2

1

Probably you are not changing the value of video.paused

 playButton.addEventListener("click", function() {

          if (video.paused == true) {
            video.paused = false;
            // Play the video
            video.play();

            // Update the button text to 'Pause'
             document.getElementById("playbtn").src = "img/icons/pause.png";
          } else {
            video.paused = true;
            // Pause the video
            video.pause();

            // Update the button text to 'Play'
            document.getElementById("playbtn").src = "img/icons/play.png";
          }
        });
Sign up to request clarification or add additional context in comments.

Comments

0

You can reset default <button> styles via CSS. This link might be helpful for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.