我有一个id为masterResourceFor_R& D的div.但是当我在jQuery中使用这个ID来选择这个div并在其上放置一个click函数时,它不起作用.我认为这个问题是因为符号&在ID中.我没有任何重命名ID的选项.
我怎样才能在jQuery中使用这个ID?
最佳答案
忽略使用特殊字符作为id和类名称,如果可以,请更改它,如果你不能,并且你想要解决this混乱,你需要逃避该角色
原文链接:https://www.f2er.com/html/426824.html#masterResourceFor_R\&D {
color: red;
}
In CSS,identifiers (including element names,classes,and IDs in
selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646
characters U+00A0 and higher,plus the hyphen (-) and the underscore
(_); they cannot start with a digit,two hyphens,or a hyphen followed
by a digit. Identifiers can also contain escaped characters and any
ISO 10646 character as a numeric code (see next item). For instance,
the identifier “B&W?” may be written as “B\&W\?” or “B\26 W\3F”.