I was trying to get the entire HTML of an element using jQuery. Of course, .html()
grabs only the inner HTML, but I wanted to retrieve the wrapping HTML too.
Imagine the following HTML:
<div id="wrapper">
<div id="container_a">
<p>Container A</p>
</div>
<div id="container_b">
<p>Container B</p>
</div>
</div>
Now, If I would do $("#container_a").html()
I'd get <p>Container A</p>
clearly. However, I want to get the following:
<div id="container_a">
<p>Container A</p>
</div>
How would I achieve this?