Bug Tracker

Modify

Ticket #2640 (closed enhancement: invalid)

Opened 5 years ago

Last modified 4 years ago

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

comment:1 Changed 5 years ago by alexpkeaton

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.

comment:2 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.