title: JavaScript find element by text
body: <p>I'm in an environment don't have jQuery.
  I want to find the tag or tags that contain certain text.
  The DOM looks like this:</p>
  
  <pre><code>&lt;div&gt;
      &lt;div&gt;
          &lt;h2&gt;contain certain text&lt;/h2&gt;
      &lt;/div&gt;
      &lt;div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I was using XPath to locate this div.</p>
  
  <pre><code>var linkBox = document.evaluate(
      '//h2[contains(text(),"certain text")]/../..', 
      document, 
      null, 
      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, 
      null )
  </code></pre>
  
  <p>It works fine. Until I found out IE doesn't support XPath in document. 
  Now I'm doing <code>getElementsByTagname('h2')</code> and then enumerate the whole set to check the innterText.</p>
  
  <p>Is there a better way to do this?</p>