XPath在JQuery选择器中不起作用(JQuery版本1.7.1)

Mac*_*ver 1 jquery xpath jquery-selectors jquery-1.7

下面是一个工作的jQuery选择器,并将值正确设置到文本框中.为什么jQuery选择器中的XPath代码不起作用?我认为jQuery支持XPath.

jQuery代码工作:

$('html > body > form > div:nth-child(4) > label > input').val('hello world');
Run Code Online (Sandbox Code Playgroud)

jQuery代码不起作用:

$('/html/body/form/div[4]/label/input[1]').val('hello world');
Run Code Online (Sandbox Code Playgroud)

文档在这里:

http://docs.jquery.com/DOM/Traversing/Selectors

...在上面的文档中搜索此代码.... $("/html/body//p")

Bol*_*ock 7

jQuery不再支持开箱即用的选择器的XPath语法.

如果你查看你链接到的文档,你会看到它是版本1.1.2,来自5年多以前的版本.它还说,在一个带有居中文字的大红色框中:

这是Selectors API的旧版本:

查看当前API