Dom Find Element By Xpath
I'm new to DOM querying and I'm wondering if it is possible to query DOM elements directly by Xpath in a similar way to the below-mentioned code? document.getElementById('searchInp
Solution 1:
The equivalent statement using only XPath would be
xPathResult = document.evaluate('//*[@id="searchInput"]', document);
if(xPathResult){
element = xPathResult.iterateNext();
}
Have a look at the Intro to XPath in the browser on MDN for some more examples and usages.
Post a Comment for "Dom Find Element By Xpath"