Change tag using JavaScript | Span to div example code

How can I change a tag with pure JavaScript like that?

change span tag to div tag etc.

Example how to Change tag using JavaScript

Use innerHTML and replace method with regular expression to change tag name JS.

Output:

Change tag using JavaScript

Do comment if you have another example or way to do it. You can also do comment if have any suggestions or doubts on this topic.

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.