Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 7 years ago

#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:
Blocked by: Blocking:

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 (3)

comment:1 Changed 9 years ago by addyosmani

Priority: undecided
Resolution: invalid
Status: newclosed

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.

comment:2 Changed 7 years 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 7 years ago by dmethvin

This seems to work for me as of 1.8.2: http://jsfiddle.net/xnRgW/

Note: See TracTickets for help on using tickets.