title: run jQuery on variable and not on document
body: <p>Do you know if it's possible to run jQuery on a variable that contains html and not just on the document itself.</p>
  
  <p>Example:</p>
  
  <pre><code>bg.inspectorGetRawHtml = function(){
      var c = jQuery("#bg-admin-inspect-wrapper").html();
      jQuery(".bg-admin-inspect-state", c).remove();
      console.debug(c);
  }
  </code></pre>
  
  <p>So bascially, reading a segment of the pages html into a variable and then performing jQuery manipulation on that string.</p>
  
  <p>If I console.debug the actual jQuery remove, it seems like does the matching, but the var is not manipulated.  I know jQuery relies on the DOM, and maybe that's why it's not working, but if anyone has any insight on this....
  <strong>Edit</strong>
  After lonesomeday's suggestion, here is the code I ended up with:</p>
  
  <pre><code>bg.inspectorGetRawHtml = function(){
      var c = jQuery("#bg-admin-inspect-wrapper").clone();
      jQuery(".bg-admin-inspect-state", c).remove(); //The ,c specifies what element to work on.
      console.debug(c.html());
  }
  </code></pre>