Reputation: 1565
I'm trying to use the :contains selector to more efficiently grab some elements. However, I'm not sure on the syntax for:
:contains(X AND Y)
:contains(X(any number of characters)Y)
X/Y are variables.
I could not find anything searching online that specifics using the :contains selector. All I found were fancy class selectors like ~=word and such.
Upvotes: 2
Views: 853
Reputation: 5995
There is no wildcard or logic applicable to :contains
selector. It just matches the string inside it, but you can get by with these approaches.
For :contains(X AND Y)
you can can combine two consecutive :contains selectors :contains(X):contains(Y)
, which matches 'X' and 'Y' strings.
For :contains(X(any number of characters)Y)
there is a question already answered that extends jQuery to add :starts-with()
and :ends-with()
. Combining both of them :starts-with(X):ends-with(Y)
you get results that contains 'X(any number of characters)Y'.
jQuery selector that simulates :starts-with or :ends-with for searching text?
Upvotes: 2