Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shield "." char? [duplicate]

Possible Duplicate:
How do I get jQuery to select elements with a . (period) in their ID?

I tried to run the following code:

$('#info-mail.ru .domain-info').toggle();

example here

And #info-mail.ru as I understood interpreted as id="info-mail" and class="ru", but I have the following structure:

<div id="info-mail.ru">
    <p class="domain-info">
        Some cool info
        Some cool info
        Some cool info
        Some cool info
    </p>
</div>

How can I shield "." char in selector statement? Or the only way is to replace all "." with "_" (for example)?

TIA!

like image 658
Dmitry Belaventsev Avatar asked Sep 30 '11 09:09

Dmitry Belaventsev


1 Answers

Escape . with a double backslash, one for the literal and the other for jQuery:

$('#info-mail\\.ru .domain-info').toggle();

See jQuery FAQ for details.

like image 54
Saul Avatar answered Oct 05 '22 23:10

Saul