Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are lots of ways, Here are some.</p> <pre><code>&lt;img id="bannerLogo" src="/path/to/image/logoup.png" /&gt; &lt;script type="text/javascript"&gt; var imageCounter = 0; $('#bannerLogo').click(function(){ if(imageCounter%2==0){ $('#bannerLogo').attr('src', '/path/to/image/logodown.png'); } else { $('#bannerLogo').attr('src', '/path/to/image/logoup.png'); } imageCounter++; }); &lt;/script&gt; </code></pre> <p>Or </p> <p>(Note - As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().)</p> <pre><code>&lt;img class="swapper" src="imagename_off.jpg" /&gt; &lt;script type="text/javascript"&gt; $(function(){ $(".swapper").live('click', function() { if ($(this).attr("class") == "swapper") { this.src = this.src.replace("_off","_on"); } else { this.src = this.src.replace("_on","_off"); } $(this).toggleClass("on"); }); }); &lt;/script&gt; </code></pre> <p>I hope this helps.</p> <p>Ill also add in my hover script, just in case you need it at some point:</p> <pre><code>$('#bannerLogo').hover( function() { $('#bannerLogo').attr('src', '/path/logodown.png');}, function() { $('#bannerLogo').attr('src', '/path/logoup.png'); }); </code></pre> <p>Don't forget to include JQuery lib</p> <p><a href="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" rel="nofollow">http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js</a></p> <p>Thanks, Philip</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload