JavaScript get image source from img tag | HTML Example code

Just grab the element by its id using getElementById and then just use .src to get image src JavaScript. Image source can URL format.

Example: How to JavaScript get image source

Here is an HTML example code of getting src of the image in JS. We are using variables to store source value.


JavaScript get image source

Let’s us know if you know any other way or have better example. You can do also comment any suggestions.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.