title: How to filter an html ajax response's elements before inserting into document?
body: <p>I am working with a server that responds with an HTML response of the form:</p>
  <pre><code>&lt;div&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Country&lt;/th&gt;
    &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;John Doe&lt;/td&gt;
        &lt;td&gt;USA&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;James Doe&lt;/td&gt;
        &lt;td&gt;Canada&lt;/td&gt;
      &lt;/tr&gt;
       &lt;tr&gt;
        &lt;td&gt;Jonas Doe&lt;/td&gt;
        &lt;td&gt;UK&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  <p>My problem is that, before I insert this table, I want to filter the rows.
  For example, let's say I wanted to only have the rows with USA as the value in the second cell.</p>
  <p>How could I do this?</p>
  <p>Here's my current status in trying to solve this problem.</p>
  <p><a href="https://jsfiddle.net/bmp6a4gh/" rel="nofollow noreferrer">https://jsfiddle.net/bmp6a4gh/</a></p>
  <p>In essence, Im trying to create a function that accepts the html string and injects a string (of the same format) but with the filtered rows.</p>
  <pre><code>function processResponse(html){
    var $html = $(html);
    //perform filtering here
    //I only want elements from USA
    $html.filter(function(index, element){
      return true;
    });
    $(&quot;#response&quot;).html($html);
  }
  </code></pre>