I have a image in my HTML file like this.
<img src="@routes.Assets.versioned("images/bell.png")" width="200", height="200" id = "symbolImg">
Image file is stored here.
Output
I was trying to change the image by having the following code in a typescript file.
document.getElementById("changeImageBtn").addEventListener("click", function () {
document.getElementById("symbolImg").setAttribute("src", "@routes.Assets.versioned('images/cherry.png')" );
document.getElementById("symbolImg").setAttribute("width", "300");
document.getElementById("symbolImg").setAttribute("height", "300");
});
But the image doesn't change. This is the output.
Edit 1
Also tried these ways with escape characters. Had no effect.
document.getElementById("symbolImg").setAttribute("src", "@routes.Assets.versioned(\"images/bell.png\")" );
.
document.getElementById("symbolImg").setAttribute("src", "@routes\.Assets\.versioned\(\"images/bell\.png\"\)" );