gpt4 book ai didi

javascript - jquery 和 javascript 的不同结果

转载 作者:搜寻专家 更新时间:2023-11-01 04:44:00 25 4
gpt4 key购买 nike

我有一个 id 为 param0.typeParameter 的选择。

我尝试使用 jquery 获取它:

$('#param0.typeParameter');

如果它使用这个,我什么也得不到

document.getElementById('param0.typeParameter');

有效

最佳答案

让 jQuery 选择 ID 为 param0.typeParameter 的元素而不是 ID 为 param0 的元素和类(class)名称 typeParameter你应该使用以下内容:

$('#param0\\.typeParameter');

官方证明

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^``{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar").

来源: http://api.jquery.com/category/selectors/

演示: http://jsfiddle.net/LtRxg/

关于javascript - jquery 和 javascript 的不同结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20077589/

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