I did a run-in of images (at first I do without tutorials), and I want to know if there is a way to kill a script if one image ends with over.jpg and makes the script continue if the image is not
this is my code
$('#topNav a img').hover(function(){ var rSrc = $(this).attr('name'); $(this).attr('src','images/' + rSrc + 'over.jpg'); }, function(){ var rSrc = $(this).attr('name'); $(this).attr('src', 'images/' + rSrc + '.gif'); });
HTML
<a href="index.html" class="nav"><img src="images/m_1over.jpg" name="m_1"/></a> <a href="aboutus.html" class="nav"><img src="images/m_2.gif" name="m_2"/></a>
I tried adding
if($('img[src$=.gif]')
before the script, but it does not work ...
source share