HomeTutorsContact
JavaScript
How to get inner html with JavaScript?
Gulshan Saini
May 31, 2020
1 min

In this quick tutorial I am going to show you how you can get inner html contents(markup) of any element using property element.innerHTML

Tip: You can even use element.innerHTML to set markup of any element

Let’s start with following markup

Now, we are going to get following paragraph element markup

First, we need to get the reference of parent element, which is <div id="main"> in our case

Next, we can to get the inner html and log it to console as follows

Output

Summary

  • The element.innerHTML can be used to get or set inner html of eny element

Tags

#dom-manipulation
Previous Article
How to replace inner html with JavaScript?

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Related Posts

How to iterate through NodeList using Javascript?
July 09, 2020
1 min
© 2020, All Rights Reserved.

Quick Links

Advertise with usContact Us

Social Media