title: How to remove an element from a variable using jQuery
body: <p>I want to remove 2nd occurrence of th element from below variable </p>
  
  <pre><code>var t1= 
  '&lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt; &lt;/th&gt;
              &lt;th&gt;first&lt;/th&gt;
              &lt;th&gt;second&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;...&lt;/tbody&gt;
  &lt;/table&gt;';
  </code></pre>
  
  <p>I tried doing</p>
  
  <pre><code>$(t1).find('thead').children().slice(2).detach(); 
  </code></pre>
  
  <p>It doesn't work.</p>
  
  <p>I also tried below</p>
  
  <pre><code>var ndx = 2;
  
  $(t1).find('thead').remove(":nth-child(" + ndx + ")");
  </code></pre>
  
  <p>It also doesn't work.</p>
  
  <p>I know it shouldn't be that complicated. Could someone help me out how to remove element using jQuery </p>
  
  <p>Thanks</p>