javascript - JS element style switching -


I have to switch two elements of my element background image bitwin on every click.

I have this, byte switches it in color twice = =

   & Lt; / Center & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Some browsers may be giving you the full path of the image instead of the relative path < Instead of / p>

== , test for the status of the URL indexOf () .

Example: (Click on the button several times to see the URL change)

  Change the function device ( ) {Var imgpath = new string (); Var div = document.getElementById ("div1"); ImgPath = div.style.backgroundImage; Div.style.backgroundImage = (imgPath.indexOf ("blue.png") & gt; -1. IMGpath == "")? "Url (green.png)": "url (blue.png)"; }  

Edit: if () has been updated to replace with a threesome.


Comments