SO - 20573153
by Arun P Johny
HTML
<img src="1.svg" onerror="this.onerror=null; this.src='http://placehold.it/200x200/1.png'; this.className+=' myclass';" class="image" id="1" />
CSS
.myclass {
margin-left:50px;
}
JavaScript
$(function () {
$(document).on('mouseover', ".myclass", function () {
var src = $(this).attr("src").replace('1.png', 'ff0000.png');
$(this).attr("src", src);
}).on('mouseout', ".myclass", function () {
var src = $(this).attr("src").replace('ff0000.png', '1.png');
$(this).attr("src", src);
});
});