Skip to content

Instantly share code, notes, and snippets.

@knu2xs
Last active January 4, 2016 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knu2xs/8541266 to your computer and use it in GitHub Desktop.
Save knu2xs/8541266 to your computer and use it in GitHub Desktop.
Locate a DOM element using XPath and return as JS DOM object instance for further mainpulation
function xpathObject (xpathString) {
return document.evaluate(
xpathString,
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment