Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///scroll to element by xpath
- ///tested at: https://www.w3schools.com
- function getElementByXpath(path) {
- return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
- }
- function findPos(obj) {
- var curtop = 0;
- if (obj.offsetParent) {
- do {
- curtop += obj.offsetTop;
- } while (obj = obj.offsetParent);
- return [curtop];
- }
- }
- //calling:
- window.scroll(0,findPos(getElementByXpath("//a[contains(text(),'LEARN JQUERY')]")));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement