Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble with attribute != selector

The question is simple, the answer maybe not.

I'm trying to apply several styles to all input elements without an specific id. I use this selector in my CSS stylesheet: input[id!='move'] but unfortunately it's not working either in IE10 or in Chrome.

The curious thing is that this block: input:not(#move) works perfectly in both. I'm lost because the first block of code is supposed to work as far as I understand how these kind of selectors work.

Any ideas?

like image 636
Des Grieux Avatar asked Jul 28 '13 02:07

Des Grieux


People also ask

How do I use attribute selector?

CSS [attribute^="value"] Selector The [attribute^="value"] selector is used to select elements with the specified attribute, whose value starts with the specified value. The following example selects all elements with a class attribute value that starts with "top": Note: The value does not have to be a whole word!

What is a attribute selector?

The CSS Attribute Selector is used to select an element with some specific attribute or attribute value. It is an excellent way to style the HTML elements by grouping them based on some specific attributes and the attribute selector will select those elements with similar attributes.

How do you select an element with a class attribute?

Matches elements with an attr attribute whose value is exactly value or begins with value immediately followed by a hyphen. In the example below you can see these selectors being used. By using li[class] we can match any list item with a class attribute. This matches all of the list items except the first one.


1 Answers

That is a non-standard attribute selector invented by jQuery. It's not part of the Selectors specification, so it won't work anywhere outside of jQuery (this includes things like document.querySelectorAll()).

Strictly speaking, the direct equivalent of jQuery's input[id!='move'] in standard selector syntax is input:not([id='move']), with an attribute selector. But since you're looking to match elements without a specific ID, input:not(#move) is fine.

like image 138
BoltClock Avatar answered Sep 20 '22 08:09

BoltClock