I have an \"uncaught exception: Syntax error, unrecognized expression: )\" in a jQuery application.
The code is:
I have used this answer in order to solve a similar problem.
I want to prevent the use of "
and '
When using $("p:contains('" + valor + "')").addClass("on");
, it works.
But when using $('p:contains('" + valor + "')**'**).addClass("on")
, it does not!
Old question, but I must leave a note for future generations. Andrew's answer (the accepted one) didn't work for me. What did work was using a pre-made string as selector. Borrowing OP's examples:
var selector = "p:contains("+ vtxt +")";
$(selector).addClass("on");
Try this:
$("p:contains('" + vtxt + "')").addClass("on");