Js查找元素技巧 2018-12-24 JS 文章目录 使用 xpath 查找: 1 2 3 4 5 6 7 8 9 10 11 function getElementByXpath(path) { return document.evaluate( path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; } console.log(getElementByXpath("//html[1]/body[1]/div[1]")); 文章作者 DaZiYuan 上次更新 2018-12-24