title: jQuery select element by XPath
body: <p>I have an XPath selector. How can I get the elements matching that selector using jQuery?</p>
  <p>I've seen <a href="https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript" rel="nofollow noreferrer">https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript</a> but it doesn't use jQuery, and it seems a little too verbose, and I suppose it's not cross-browser.</p>
  <p>Also, this <a href="http://jsfiddle.net/CJRmk/" rel="nofollow noreferrer">http://jsfiddle.net/CJRmk/</a> doesn't seem to work.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>alert($("//a").length);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;a href="a1.php"&gt;&lt;/a&gt;
  &lt;a href="a2.php"&gt;&lt;/a&gt;</code></pre>
  </div>
  </div>
  </p>