Bug Tracker

Opened 9 years ago

Closed 9 years ago

#7967 closed bug (invalid)

using multiple selector [type!=value] results in ignoring the negative selector and selects all elements

Reported by: zxurian@… Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

Test Case - http://jsfiddle.net/NAwrU/7/

Using $("input[type!='submit']") or $("#input[type!='hidden']) correctly selects all inputs of type not submit, or of type not hidden, but if you try to combine them $("input[type!='submit'], input[type!='hidden']) it instead selects all input elements. Test case is linked at top either of the first two lines works properly, but the third line incorrectly changes all elements.

Change History (1)

comment:1 Changed 9 years ago by ajpiano

Resolution: invalid
Status: newclosed

This is not a bug. I attempted to explain this last night on IRC but you must have missed the explanation. If you want to select elements that match all the criteria, you have to combine those criteria into a single selector.

$("input[type!='submit'][type!='hidden]")

The reason yours finds all the inputs is that first, it gets the inputs that don't have type "submit", which includes elements that do have the type "hidden". Then it gets all elements that don't have the type "hidden", which includes elements that do have the "submit". The comma that separates multiple selectors can be considered to be a logical OR, not AND.

http://jsfiddle.net/NAwrU/8/

Note: See TracTickets for help on using tickets.