加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

jquery – 在CSS选择器中使用&

发布时间:2020-12-14 23:19:29 所属栏目:资源 来源:网络整理
导读:我有一个id为masterResourceFor_R D的div.但是当我在jQuery中使用这个ID来选择这个div并在其上放置一个click函数时,它不起作用.我认为这个问题是因为符号在ID中.我没有任何重命名ID的选项. 我怎样才能在jQuery中使用这个ID? 最佳答案 忽略使用特殊字符作为i

我有一个id为masterResourceFor_R& D的div.但是当我在jQuery中使用这个ID来选择这个div并在其上放置一个click函数时,它不起作用.我认为这个问题是因为符号&在ID中.我没有任何重命名ID的选项.

我怎样才能在jQuery中使用这个ID?

最佳答案
忽略使用特殊字符作为id和类名称,如果可以,请更改它,如果你不能,并且你想要解决this混乱,你需要逃避该角色

#masterResourceFor_R&;D {
   color: red;
}

Demo

Reference

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 “B26 W3F”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读