Replace image with text JavaScript | Example code

Use getElementsByTagName method to Replace image with text JavaScript. This method returns a live node list so every time you replace a node the list changes, so you only want to get the first node in the list and replace it.

Example of how to Replace image with text JavaScript

First, select any element you want change.

Then Replace it (div to p)

Compete HTML example code:

Output:

HTML Replace image with text JavaScript

Do comment if you have any doubts and suggestion on this tutorial.

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.