[ACCEPTED]-jQuery: Get HTML including the selector?-jquery-selectors
In this specific case:
var outerHTML = $("<div />").append($('#example').clone()).html();
See this page for more details.
And 3 the discussion here: http://api.jquery.com/html/ (this explains that 2 this isn't in jQuery core and why some logical 1 solutions won't work)
You could try this:
var html = $('<div>').append($('#example').clone()).html();
More Related questions