javascript - Inner HTML if statement not recognizing a div tag -


i tested following code in ie, chrome, , firefox , not work in of them. have read several questions similar problems have not offered solutions fix example.

i trying create pause/play button interfaces jwplayer (i want interface flowplayer, once button working) , image change depending on image there. have stop button stops player , changes image of pause/play button pause.

here current code:

<script type="text/javascript"> function changeimg() {   var obj = document.getelementbyid('image1');   var imgtag1 = '<img src=\'play.png\'>';   var imgtag2 = '<img src=\'pause.png\'>';   if(obj.innerhtml == imgtag2)   {obj.innerhtml = imgtag1;}   else   {obj.innerhtml = imgtag2;}   return; }  function playimg() {   document.getelementbyid('image1').innerhtml = '<img src=\'play.png\'>';   return; }  </script>  <div id="image1" href="#" onclick="changeimg(); jwplayer('mediaspace1').play(); jwplayer('mediaspace2').play(); jwplayer('mediaspace3').play(); jwplayer('mediaspace4').play();"><img src='play.png'></div> <div href="#" onclick="playimg(); jwplayer('mediaspace1').stop(); jwplayer('mediaspace2').stop(); jwplayer('mediaspace3').stop(); jwplayer('mediaspace4').stop();"><img src='stop.png'></div> 

the play/pause function works, , first div change pause img (so javascript going through) , change play if click on second div (stop function - triggers playimg() ) not change play image if click on pause button again.

for security reasons can't link website, appreciated

it looks want change src of img tag, not entire innerhtml. machineghost mentions in comment, there may whitespace added or other changes full html may make comparison come out false.

however, check if obj.src == "play.png" , set src attribute directly. this:

function changeimg() {   var obj = document.getelementbyid('image1');   var img1 = 'play.png';   var img2 = 'pause.png';   if(obj.src == img2)   {obj.src = img1;}   else   {obj.src = img2;}   return; } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -