html - can't change background image using javascript -


i trying change background image when clicking play button, background image supposed change pause, vice versa. can play , pause music, can not change images. can tell me problem is? here code:

function initaudioplayer() {     audio_0 = new audio();     audio_0.src = "audio/footprint.mp3";      //set object reference     playbtn0 = document.getelementbyid("audio-play-images-0");     forwardbtn0 = document.getelementbyid("audio-next-images-0");     backbtn0 = document.getelementbyid("audio-prev-images-0");      //add event handling     playbtn0.addeventlistener("click", playpause);     forwardbtn0.addeventlistener("click", playforward);     backbtn0.addeventlistener("click", playback); }  function playpause() {     if (audio_0.paused) {         audio_0.play();         playbtn0.style.backgroundimage = 'url(../img/pause-on.png)';     } else {         audio_0.pause();         playbtn0.style.backgroundimage = "url('../img/play-on.png')";     } } 

html

<div class="audio-controls">      <div id="audio-prev-images-0"></div>      <div id="audio-play-images-0"></div>      <div id="audio-next-images-0"></div> </div> 

if there background-image attribute in css, needs overwritten, playbtn0.css.backgroundimage = url(yourpath/img) overwrite in css.

then should see difference. should make sure css has background-size of contain fits.

edit: tagged jquery - use .style


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -