Guess i made a mistake again. :P This should work now, if not i'll eat my shoe.
$('.nav a img').hover( function(){ if($(this).attr("src").indexOf("_on") == -1) { var newSrc = $(this).attr ("src").replace(".png","_on.png"); $(this).attr("src",newSrc); } }, function(){ if($(this).parent().attr("href") != window.location.href) { if($(this).attr("src").indexOf ("_on.png") != -1) { var oldSrc = $ (this).attr("src").replace("_on.png",".png"); $(this).attr ("src",oldSrc); } } } ); var activePage = window.location.href; $("a[href="+activePage+"] img").trigger("mouseover");