with select view:

$('#user@mail.com') 

browser throws error:

Uncaught Error: Syntax error, unrecognized expression: #user@mail.com

How to escape the @ symbol?

  • one
    If I'm not mistaken, put the \ character in front of the dog. At least, the output of special characters into a string like this happens in js - Anthony_L

2 answers 2

 $('#user\\@mail\\.com') 

Help here http://api.jquery.com/category/selectors/

To use any of the meta-characters (such as! "# $% & '() * +,. / :; <=>? @ [] ^` {|} ~) As a literal part of the name, it must be escaped with two backslashes: \. For example, an element with id = "foo.bar", you can use the selector $ ("# foo \\ bar").

  • one
    You must also remember to screen a point, otherwise there will be a completely different selector. - ArtResh

another option ...

 $('[id="user@mail.com"]').text('Введите запрос'); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="user@mail.com"></div>