Possible Duplicate:
Get selected element’s outer HTML
show a string of my div and append
With the code below I need to alert this <div id="myDiv"><h1>test</h1></div>
but my code alerts this <h1>test</h1>
How do I do this? thanks
Here is my fiddle http://jsfiddle.net/5GCEQ/
<div id="myDiv">
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
</div>
var s = $('#myDiv').html('<h1>test</h1>');
alert(s.html()); //alerts <h1>test</h1>
//
//but I want it to alert <div id="myDiv"><h1>test</h1></div>
//