[jQuery] :contains working with text, but not with variable

[jQuery] :contains working with text, but not with variable


Hi guys,
I've already read the other thread on this topic and tried the
following versions of the statement:
$sites = $(data).find('categories').filter(':contains($category)');
$sites = $(data).find('categories').filter(':contains("+ $category
+")');
$sites = $(data).find('categories').filter(':contains(" \' " +
$category " \' ")');
(The variable is $category, and it contains plain text.) All of these
return no results. When I use text:
.filter(':contains(JavaScript)')
the statement works, so I know it's not the rest of the statement
that's the problem.
Can someone shed light on what the proper syntax is for
using :contains with a variable name?
Thank you,
Precar.

















    • Topic Participants

    • mg