Skip to content

Instantly share code, notes, and snippets.

@xarimanx
Created February 21, 2014 06:30
Show Gist options
  • Save xarimanx/9129767 to your computer and use it in GitHub Desktop.
Save xarimanx/9129767 to your computer and use it in GitHub Desktop.
find by xpath
(function($) {
$.xpath = function(exp, ctxt) {
var item, coll = [],
result = document.evaluate(exp, ctxt || document, null, 5, null);
while (item = result.iterateNext())
coll.push(item);
return $(coll);
}
})(jQuery);
$.xpath("//a[@href='#']").click(function () { return false; });
@xarimanx
Copy link
Author

5 == XPathResult.ORDERED_NODE_ITERATOR_TYPE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment