gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 06:17:24 25 4
gpt4 key购买 nike

下面是一个可以运行的 jQuery 选择器,并且值已正确设置到文本框中。为什么 jQuery 选择器中的 XPath 代码不起作用?我以为 jQuery 支持 XPath。

jQuery 代码工作:

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

jQuery 代码不起作用:

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

此处的文档:

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

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

最佳答案

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

如果您查看链接到的文档,您会发现它适用于版本 1.1.2,这是 5 年前的内容。它还在一个带有居中文本的大红色框中中表示:

This is an old version of the Selectors API:

View the Current API

关于jquery - XPath 在 JQuery 选择器中不起作用(JQuery 版本 1.7.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10092930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com