Modify ↓
Ticket #6219 (closed bug: invalid)
:contains breaks with (
| Reported by: | lexxx | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.4.3 |
| Component: | selector | Version: | 1.4.2 |
| Keywords: | contains parenthesis | Cc: | |
| Blocking: | Blocked by: |
Description
if the quoted needle contains ( without a closing ), it throws an exception: uncaught exception: Syntax error, unrecognized expression:
i think finding this kind of text should be allowed
$('li:contains("xxx(yyy")'); exception
Change History
comment:1 Changed 3 years ago by addyosmani
- Priority set to undecided
- Status changed from new to closed
- Resolution set to invalid
comment:2 Changed 8 months ago by pwolk@…
This doesn't work:
$("td:contains('\\(')")
I get: "Syntax error, unrecognized expression: '\(')"
And this doesn't work:
$("td:contains('\(')")
I get: "Syntax error, unrecognized expression: '(')"
comment:3 Changed 8 months ago by dmethvin
This seems to work for me as of 1.8.2: http://jsfiddle.net/xnRgW/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

The main reason that this isn't working is that you're not escaping the special characters (eg ") that you're trying to use in your selector. As per the jQuery documentation on selectors:
If you wish to use any of the meta-characters (#;&,.+*~':"^$[]()=>|/@ ) as a literal part of a name, you must escape the character with two backslashes:
.
Closing as invalid.