Ticket #2640 (closed enhancement: invalid)
CSS ~= attribute selector
| Reported by: | alexpkeaton | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.2.4 |
| Component: | core | Version: | 1.2.3 |
| Keywords: | Selectors | Cc: | |
| Blocking: | Blocked by: |
Description
There should be a ~= selector to select elements with an exact match where attribute values are separated by spaces. For example, suppose I have this HTML fragment:
<div class="button on"></div> <div class="button off"></div>
I would expect to select the "on" element with this:
$("div[class~=button][class~=on]");
The *= selector is similar, but fails in this example because the word "button" contains "on". Alternatively, this works:
$("div[class*=button on]");
But that requires attribute values to be in a specific order, which is not desirable.
Best regards,
Nathan Bryan
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This isn't necessary. I found using a selector like ".button.on" will work just fine. I guess I wasn't aware that was possible because IE6 doesn't support that so nobody typically does it that way.