html - src image changer after click with JavaScript -


i have image in html page:

<img src="/images/deactivate.png" onclick="act_deact(this);"/> 

and in javascript code have this:

function act_deact(image) {     image.src = (image.src=="/images/activate.png" ) ? "/images/deactivate.png" : "/images/activate.png"; } 

and when click on image deactivated activate in second click doesn't desactivate !

is there probleme code ?

from js amateur :)

this because when set to(or changes to) /images/activate.png on first click, src attribute no longer /images/activate.png gets prefixed server-address.

you can check here: http://jsfiddle.net/hgcqq/

or on own server, use console.log or alert if prefer.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -