How To Get Div And Full Inner Content In Javascript?
I want get div inner content in javascript Ex:
contentcontentcontent
Solution 1:
Use getElementById() to get the element and innerHTML to get tht content
document.getElementById('content').innerHTML;
To get the content of the whole tag , use outerHTML
document.getElementById('content').outerHTML;
Solution 2:
You can try this piece of code to retrieve inner content
varMyDiv1 = document.getElementById('content').innerHTML;
Solution 3:
If you want to retrieve the content that is inside the div, you can use document.getElementById("content").innerHTML. This will return
content<br>content<br>content<br>
But if you want to retrieve the html with div tags included, you can try using document.getElementById("contents").outerHTML. This will return you
<divid="content"style="height: 20px; overflow: hidden">
content<br>content<br>content<br></div>
Post a Comment for "How To Get Div And Full Inner Content In Javascript?"