Special characters in selectors
If you wish to use any of the meta-characters described above as a literal part of a name, you must escape the character with a backslash (\). Since Javascript uses the backslash for escape sequences in string literals, you must use two backslashes (\\) in string literals so that a single backslash will be put into the string 1.
Example: "#foo\\:bar"
"#foo\\[bar\\]"
"#foo\\.bar"The full list of characters that need to be escaped: #;&,.+*~':"!^$[]()=>|/
google 翻译在选择器的特殊字符
如果你想使用的任何元以上,作为一个名称文字的一部分,您必须摆脱以反斜杠字符描述的字符(\)。由于Javascript中使用字符串的反斜杠转义序列,你必须使用两个反斜杠(\ \)的字符串,使一个反斜杠将纳入字符串1付诸表决。 例如: “#富\ \:酒吧”
“#富\ \ [酒吧\ \]”
“#富\ \。酒吧说:”需要被转义字符的完整列表:#;&,.+*~':"!^$[]()=>|/
If you wish to use any of the meta-characters described above as a literal part of a name, you must escape the character with a backslash (\). Since Javascript uses the backslash for escape sequences in string literals, you must use two backslashes (\\) in string literals so that a single backslash will be put into the string 1.
Example: "#foo\\:bar"
"#foo\\[bar\\]"
"#foo\\.bar"The full list of characters that need to be escaped: #;&,.+*~':"!^$[]()=>|/
google 翻译在选择器的特殊字符
如果你想使用的任何元以上,作为一个名称文字的一部分,您必须摆脱以反斜杠字符描述的字符(\)。由于Javascript中使用字符串的反斜杠转义序列,你必须使用两个反斜杠(\ \)的字符串,使一个反斜杠将纳入字符串1付诸表决。 例如: “#富\ \:酒吧”
“#富\ \ [酒吧\ \]”
“#富\ \。酒吧说:”需要被转义字符的完整列表:#;&,.+*~':"!^$[]()=>|/
解决方案 »
- 关于Jquery/js滚动条和页面元素位置的问题
- 求大于0小于10万的正整数的正则表达式
- 如何实现JSP站内搜索结果中关键字前后20个字以外用省略号代替?
- javascripts动态嵌入的页面怎么才能抓到呢
- js 实现代吗
- 用firefox就不好用了!大家帮帮忙啊
- 级联下拉菜单取值的问题,着急在线等。。。
- 送分:获取3个单行文本框的字符串,通过1个按钮输出结果!
- www.51js.com这个网站怎么上不去了? 最近有谁上去过吗??
- 如何自动关闭本页?
- Javascript得到实际显示网页内容的高度,不是类似这几个的:availHeight,availHeight。。
- 请教个frames嵌套 的问题
如
<div id="id#b">bb</div>
<div id="id[1]">cc</div>如果按照普通方式
$('#id#b');
$('#id[1]');
获取就不能正确获取到。这时就可以用转义,正确写法如下:
$('#id\\#b');
$('#id\\[1\\]');