title: Extract Text and Specific Elements from a String Containing HTML
body: <p>There's a similar thread here, but it only deals with parsing Element-only HTML strings.</p>
  
  <p><a href="https://stackoverflow.com/questions/3754092/how-to-get-an-html-element-from-a-string-with-jquery">How to get an HTML element from a string with jQuery</a></p>
  
  <p>In my case, I have an HTML string <strong>combining plain text with element(s)</strong>.</p>
  
  <pre><code>var str = 'Some text ' + 
            '&lt;input type="hidden" id="hiddenField" value="3" /&gt; ' +
            '&lt;input type="text" id="textField"/&gt;';
  </code></pre>
  
  <p>I need the following 2 functions,
  (1) Extract Plain Text from this string, (2) Extract Element by ID.</p>
  
  <p>Examples: </p>
  
  <p>(1) <code>getText(str) =&gt; 'Some text ';</code></p>
  
  <p>(2) <code>getElement(str, id) =&gt; jQuery element variable</code></p>
  
  <p>I was going to split by ID, and then split by <code>&lt;</code>/<code>&gt;</code> multiple times, then stitch together different strings, but that doesn't seem elegant, wondering if there are better ways.</p>