On a js script, I have a div which I add dynamically some childs. So from the beginning, I can't know how many childs my div will contains.
When I try to get the innerHTML of my div container, I only obtains the html of the div. Not the html of the node.
How can I get the innerHTML of the whole components, through the childs ?
Try this:
document.getElementById('MyId').outerHTML
This gets all the html of the element, inside and itself.
使用outerHTML
就可以了。
document.getElementById('YourId').outerHTML
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.