src.replace() javscript code example
Example 1: javascript change image src
//change image src
document.getElementById('myImageID').src="images/my_other_image.png";
Example 2: insert image using set atribute
var img = document.getElementById("example");
console.log(img.getAttribute("src")); // "images/foo.png"
console.log(img.src); // "http://example.com/path/images/foo.png"