If my html looked like this:
-
Short Answer: If you have an element with id="foo.bar", you can use the selector $("#foo\\.bar")
Longer Answer: This is part of the jquery documentation - section selectors which you can find here:
http://api.jquery.com/category/selectors/
Your question is answered right at the beginning of the documentation:
If you wish to use any of the meta-characters ( such as
!"#$%&'()*+,./:;?@[\]^`{|}~ )
as a literal part of a name, you must escape the character with
two backslashes: \\. For example, if you have an element with id="foo.bar",
you can use the selector $("#foo\\.bar"). The W3C CSS specification contains
the complete set of rules regarding valid CSS selectors. Also useful is the
blog entry by Mathias Bynens on CSS character escape sequences for identifiers.
- 热议问题