jQuery XPath
jQuery XPath 是一個 jQuery 插件,實(shí)現(xiàn)了全功能的 XPath 2.0 查詢語言。
示例代碼:
$(document).xpath("*"); // Returns {Element} html (direct child of context item - document)
$(document).xpath("http://head << //body"); // Returns {Boolean} true (head is preceding body)
$(document).xpath("http://*[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)評論
圖片
表情
