variables - Global boolean not working within function - Javascript -


<script> var xturn = true; function changeimage() {     element=document.getelementbyid('myimage')     if (element.src.match("/wp-content/uploads/2013/07/squaree.png") && xturn)     {         xturn = false;         element.src="/wp-content/uploads/2013/07/xx.png";     }     else if (element.src.match("/wp-content/uploads/2013/07/squaree.png") && xturn==false);     {         xturn = true;         element.src="/wp-content/uploads/2013/07/circ.png";     } } </script>  <img id="myimage" onclick="changeimage()" src="/wp-content/uploads/2013/07/squaree.png" width="90" height="90"> 

for reason xturn doesn't seem work within function. referencing if incorrectly? in wordpress, way. have checked make sure image changes without xturn being used.

i think using match wrong , element.src give complete url with

http://domain.... 

try

element.src.indexof("squaree") != -1 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -