Really dumb question but, for instance, given:
var $foo = $('<div>bar</div>');
How would I get the '<div>bar</div>'
back out?
You need to append it to a container, then call .html()
on that.
This is because .html()
only gives you the content.
Try it out: http://jsfiddle.net/ttYXG/
var $foo = $('<div>bar</div>');
$('<div />').append($foo).html();
$("<h1>Test</h1>")[0].outerHTML
Returns: <h1>Test</h1>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With