I have some code running with jQuery 1.7.2 I encountered an error when trying to find using this selector
var x = "span:contains(\"C) Foo (Bar)\")";
$('body').find(x)
https://jsfiddle.net/elewinso/dfbn82wo/7/
This issue is fixed in JQuery 1.8 and up but since I cannot switch my jQuery I was hoping to find a patch.
The problem is your selector is confusing jQuery's parser because it contains brackets. It thinks the ) you are trying to match is the closing bracket of its contains: content filter.
You can get around this by using filter() instead.
$('span').filter(function() {
return $(this).text().indexOf('"C) Foo (Bar)"') != -1;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With