User123 User123 - 1 year ago 107
jQuery Question

How to get raw html passed as jQuery selector?

Note: Answer given by SLacks requires the least code to get what I want compared to answers in the duplicate questions. Accepting this.

I'm trying to do get the raw html that's passed in as the selector:


I need just the html so


Answer Source

You're looking for the native outerHTML property: el[0].outerHTML

Note: this is not quite "raw"; this is the HTML as parsed by the browser.

example of parsed output:

$("<div></div>")[0].outerHTML = "<div></div>";    
$("<div/>")[0].outerHTML = "<div></div>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download