I want get div inner content in javascript
Ex:
<div id="content" style="height: 20px; overflow: hidden">
content<br>content<br>content<br>
</div>
This is my html code. i know only div id (content). but i want retrieved main div and their inner content via javascript like..
<div id="content" style="height: 20px; overflow: hidden">
content<br>content<br>content<br>
</div>
Also i want retrieved content div attribute also like style, class name etc.
Use getElementById() to get the element and innerHTML to get tht content
document.getElementById('content').innerHTML;
LIVE DEMO FOR INNERHTML
To get the content of the whole tag , use outerHTML
document.getElementById('content').outerHTML;
LIVE DEMO FOR OUTERHTML
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With