Checking image name using javascript
<p>I'm changing the img src on click using javascript.</p>

<p>I'm trying to determine whether to switch on or off.</p>

<p>I'm testing the following:</p>

<pre><code>var img_el = document.getElementById("on_off_img");
if ( img_el.src == 'img/on.png' ) {

  img_el.src = 'img/off.png'
} else {

  img_el.src = 'img/on.png'
}
</code></pre>

<p>My problem is that i never get a match - it looks like img_el.src returns the full URL... Is there a function to just test the actual filename instead of the full string to the file?</p>

<p>Or is there a better way to manage the click?</p>
