Dear Sirs. Actually the functionality is performed. I can not force the button to change the image of the button when turning the sound off and on. Tell me please. Thank.

function mute(btn, elem) { var video = document.getElementById(elem); if (video.muted) { video.muted = false; } else { video.muted = true; } } 
 #sounds { position: absolute; z-index: 101; width: 40px; height: 40px; border: none; padding: 0; top: 46px; left: -2px; } .btn_001 { //Π—Π°Π΄Π°Π½ΠΈΠ΅ ΠΎΠ±Ρ‰Π΅Π³ΠΎ стиля для ΠΊΠ½ΠΎΠΏΠΊΠΈ height: 40px; width: 40px; border: none; position: relative; background: lime url(../img/img_473b.png) no-repeat top center; cursor: pointer; } .btn_001:hover { //Π‘Ρ‚ΠΈΠ»ΡŒ ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΏΡ€ΠΈ Π½ΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠΈ Π½Π° Π½Π΅Π³ΠΎ курсора height: 40px; width: 40px; border: none; background: red url(../img/img_473b2.png) no-repeat top center; } .btn_001:focus { //Π‘Ρ‚ΠΈΠ»ΡŒ ΠΊΠ½ΠΎΠΏΠΊΠΈ, ΠΊΠΎΠ³Π΄Π° ΠΎΠ½Π° Π² фокусС height: 40px; width: 40px; border: none; background: red url(../img/img_473b2.png) no-repeat top center; } .btn_001:active { //Π‘Ρ‚ΠΈΠ»ΡŒ ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΏΡ€ΠΈ Π½Π°ΠΆΠ°Ρ‚ΠΈΠΈ height: 40px; width: 40px; border: none; background: lime url(../img/img_473b.png) no-repeat top center; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <div id="in"> <video id="myVideo" width="100%" height="100%" autoplay loop> <source src="img/video/zastavka_1.mp4"></source> <source src="img/video/zastavka.webm" type="video/webm"></source> </video> </div> <div id="sounds"> <button onclick="mute(this, 'myVideo')" class="btn_001"><img src="img/img_473b.png"></button> </div> 

  • and where is the sound ?????? - Excess Gophers
  • You understand the video is quite large. I understand that under the terms of the forum it is not worth shipping it. the sound itself is turned on and off, only the image of the button itself does not change humanly. If necessary, I will try to upload a video .. Ie, now it is green. Hover the cursor - becomes red. click it should remain red. Now decided to enable. The process should be in the opposite direction, with sound it happens, but with the image - no way. - Roman

1 answer 1

I can not force the button to change the image of the button when turning the sound off and on

I do not see where you are trying to change the image

Tell me please

because the picture inside the loaf - everything is very simple

 var img = btn.getElementsByTagName('img')[0]; img.src = ''