views:

41

answers:

3

I have this html

<div id"test123">
dasd'asdasd

</div>

I want the content of that div box with "<div id="test123">" itself as well not just innerhtml

I tried $('#test123').html()

But it only gave me inner html

+1  A: 

Doesn't seem to be an easy way in the box.

http://brandonaaron.net/blog/2007/06/17/jquery-snippets-outerhtml/

liammclennan
A: 
var div = $('#test123').eq(0);
console.log(div);
Jason
A: 

Pretty gnarly, but it gets the job done:

$('<div />').append($('#test123').clone()).html();
Kent