D
D
Daniel_Defo2018-02-11 12:40:36
JavaScript
Daniel_Defo, 2018-02-11 12:40:36

addEventListener not working in Chrome?

Good afternoon dear Jedi of the web. Faced the following problem: There is a code

<button id="mute" title="Mute button" >
<div><img class="img-responsive" alt="Volume on button" src="img/main-body/btn_audio.png"></div>
</button>

document.getElementById("mute").addEventListener("click", function (evt) {
          if (video.muted) {
            video.muted = false;
            evt.target.innerHTML = "<img alt='volume on button' src='img/main-body/btn_audio.png'>"
          } else {
            video.muted = true;
            evt.target.innerHTML = "<img alt='volume off button' src='img/main-body/muted.png'>"
          }
}, false);

Which changes the picture when you click on another one, and so in all browsers everything is OK, except for Chrome, it simply creates a picture inside the picture, but does not change it. link to the site
Maybe someone faced such a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bm1, 2018-02-11
@Daniel_Defo

Try replacing evt.target with this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question