$(function() { var $img = $("img"); $img.hover(function() { $(this).attr("src",$(this).attr("src").replace("_on","_off")); },function() { $(this).attr("src",$(this).attr("src").replace("_off","_on")); }); });