0

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:

$('<div></div>')

I need just the html so '<div></div>'

Thanks!

User123
  • 489
  • 8
  • 21

1 Answers1

3

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>";
freedomn-m
  • 24,983
  • 7
  • 32
  • 55
SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933