【发布时间】:2011-11-28 07:38:11
【问题描述】:
可能重复:
How do I get jQuery to select elements with a . (period) in their ID?
我尝试运行以下代码:
$('#info-mail.ru .domain-info').toggle();
据我所知,#info-mail.ru 被解释为 id="info-mail" 和 class="ru",但我的结构如下:
<div id="info-mail.ru">
<p class="domain-info">
Some cool info
Some cool info
Some cool info
Some cool info
</p>
</div>
如何屏蔽“.”选择器语句中的字符?或者唯一的方法是替换所有“。”用“_”(例如)?
TIA!
【问题讨论】:
-
有趣的是,
.在技术上在 ID 中有效:What are valid values for the id attribute in HTML? -
@Pekka:检查这也是我的第一个直觉 ;-)
标签: javascript jquery