我需要一种通过xpath选择元素的方法(非CSSpath或任何其他方法,必须严格地是xpath)
$(document).find("/html[1]/body[1]/div[4]/div[2]/div[1]/h1[1]/a[1]").css("background-color", "yellow")
这似乎不起作用。
答案 0 :(得分:6)
从jQuery中删除了对XPATH选择器的支持。在我可以收集的1.2版本中。
答案 1 :(得分:0)
方法find()使用CSS Selector,而不是XPath select。
答案 2 :(得分:-2)
您可以直接在选择器中使用xpath:
http://dev-tips.com/featured/jquery-tip-using-xpath-selectors