Possible Duplicate:
jQuery - Get selected element's outer HTML
so I have a div..
<div id="fred">
it has stuff in it
<div id="fred">
<tr id="thing1">hello1</tr>
<tr id="thing2">hello2</tr>
</div>
if I call
$("#fred").html();
I get just the items inside:
<tr id="thing1">hello1</tr>
<tr id="thing2">hello2</tr>
I want the whole thing:
<div id="fred">
<tr id="thing1">hello1</tr>
<tr id="thing2">hello2</tr>
</div>
I know that I can ref using this[0], but it seems like there should be an easier way..
I tried .andSelf() but apparently that doesn't do what I thought it should doo..
jQuery doesn't support outerHTML: http://api.jquery.com/html/#comment-84945158
(.andSelf is for element sets, not for depth.)
I think the best solution would be el[0].outerHTML (no extra 'plugin' required and native JS s always good)
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