nickf nickf - 1 year ago 79
Javascript Question

Convert a jQuery set into HTML

Given a jQuery result set, how do you convert that back into plain HTML?

<div class="abc">
foo <strong>FOO</strong>
<div class="def">


var $mySet = $('div');

, how would you go about returning to the plain HTML above?

Answer Source

If your set consists of precisely one item, you can use ye olde Javascript:

var html = $mySet[0].outerHTML; // note HTML is all caps... that always burns me
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download