How to escape ' for a:contains(...)

jquery

Solution

You can try this:

$('a:contains("This isn\'t choking on the apostrophe")')

Or this:

$("a:contains('This isn\'t choking on the apostrophe')")

Problem

How can I escape content for characters such as an apostrophe ? The following a:contains is choking on the string literal ``` $('a:contains('\This'is choking on the apostrophe\').... ```

Original source