Skip to content Skip to sidebar Skip to footer

Assign Src Of Image To A Variable Through Js In Html

I want to assign content of the src tag of image to a variable on clicking on the image through JS: Eg- HTML
+ element + "' />"; } </script></head><body><divid="img"><imgid="img1"src="image1.jpg"onclick="setImage(this.id)" ><imgid="img2"src="image2.jpg"onclick="setImage(this.id)" ></div><spanid="source"></span></body></html>

Solution 2:

you can try this,

<imgng-src="{{myVar}}">

Post a Comment for "Assign Src Of Image To A Variable Through Js In Html"