jQuery XPath 介绍
jQuery XPath 是一个 jQuery 插件,实现了全功能的 XPath 2.0 查询语言。
示例代码:
$(document).xpath("*"); // Returns {Element} html (direct child of context item - document) $(document).xpath("//head << //body"); // Returns {Boolean} true (head is preceding body) $(document).xpath("//*[parent::html][last()]") // Returns {Element} body (last child of html) $(document.body).xpath("count(ancestor::node())"); // Returns {Number} 2 (2 ancestor nodes) $(document.body).xpath("preceding-sibling::element()"); // Returns {Element} head (prev sibling) $(document.documentElement).xpath("body | head"); // Returns {Element} head and body (ordered) $(document.documentElement).xpath("body, head"); // Returns {Element} body and head (not ordered)
jQuery XPath 官网
https://github.com/ilinsky/jquery-xpath
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。