user5781009
user5781009

Reputation: 21

JQuery ':contains' selector - searching for text that includes nested parentheses

Assuming we have a table as follows:

<table>
  <tbody>
    <tr>
      <td><span>Hello (Hi) - Bye</span></td>
    </tr>
    <tr>
      <td><span>Hello (Hi (Hey)) - Bye</span></td>
    </tr>
  </tbody>
</table>

The selector $('table tbody tr:contains("Hello (Hi) - Bye")') works properly and finds the appropriate row.

However, the selector $('table tbody tr:contains("Hello (Hi (Hey)) - Bye")') fails, and the error "Syntax error, unrecognized expression: Bye'" is generated.

The only difference is the nested parentheses in (Hi (Hey)).

I've tried using double \ to escape the parentheses, but this didn't work for me.

Upvotes: 2

Views: 79

Answers (1)

Josh Crozier
Josh Crozier

Reputation: 240868

This was fixed in the jQuery 1.8 release.

You should be able to nest multiple parentheses in any of the newer version of jQuery (1.8+).

This was logged as bug #11902, which is now closed and resolved.

Upvotes: 1

Related Questions