Dynamically replace img src attribute with jQuery

This is what you wanna do:

var oldSrc="http://example.com/smith.gif";
var newSrc="http://example.com/johnson.gif";
$('img[src="' + oldSrc + '"]').attr('src', newSrc);

Leave a Comment