I have a website featuring a long list of names. To make it more oversee-able, I\'d like to put a text link in to
(on load) show all
(on clicking word \"pea
To filter out elements that contain a given class or any other attribute value, using the Attribute Contains Word Selector would be a good solution:
$("span").filter("[class~='apple']")
Actually, for the class attribute, it's even easier to just write:
$("span").filter(".apple") // or:
$("span.apple")
[This is also what Joel Potter wrote in his comment to this answer.]
That way you'll be able to match all of the below:
...
...
...
So whenever you're not 100% sure that you'll only have a single class set on an element, use the ~= operator.