8

With CSS3 both :not() selector as well as attribute contains selector are available, but while mixing the both there comes the problem, it is not working.

HTML:

<input type='text'/>
<input type='text' id="dasd_Date_asd"/>

CSS:

input[type='text']:not(input[id*='Date']) {
    display:none;
}

DEMO

Can anyone tell what is going on wrong here?

Note: There is no privilege given to us for changing the markup.

3 Answers 3

11

You can't use two selectors in not:

input[type='text']:not([id*='Date']) {
  display: none;
}
<input type='text' />
<input type='text' id="dasd_Date_asd" />

Selectors level 3 does not allow anything more than a single simple selector within a :not() pseudo-class.

Sign up to request clarification or add additional context in comments.

1 Comment

You may consider adding that the original code works nowadays without any workaround
4

You should first select input type and then cutt off the input with type id that has value "Date". your were again providing input as a selector in :not()

try this.

     input[type='text']:not([id*=Date]) {
        display:none;
    }
<input type='text'/>
<input type='text' id="dasd_Date_asd"/>

1 Comment

Yeah its working. And how can i say that my selector is invalid.?
4

As of 2021 your code actually works and you can use complex selectors in :not() statements. It works for all major browsers (https://caniuse.com/css-not-sel-list)

https://jsfiddle.net/o6x10ytc/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.