Codesnipp.it Social Code Sharing

Sergei Tatarinov

Changing img source on hover

by Sergei Tatarinov on Dec 03, 2011

$(function() { 02 $("img") 03 .mouseover(function() { 04 var src = $(this).attr("src").match(/[^\.]+/) + "xxx.png"; 05 $(this).attr("src", src); 06 }) 07 .mouseout(function() { 08 var src = $(this).attr("src").replace("over", ""); 09 $(this).attr("src", src); 10 }); 11 });

Can't see the comments? Please login first :)