Sawyer
Sawyer

Reputation: 15917

How to let css selector exclude an element?

For example I have a css style like this :

    input.validation-passed {border: 1px solid #00CC00; color : #000;}

The javascript validation framework I use will inject every input tag with a class="validation-passed" .For the elements like <input type='text' /> ... , this is ok , but for <input type='button' /> , I want this is not applied , how should I do this ?

Upvotes: 15

Views: 18112

Answers (3)

Alsciende
Alsciende

Reputation: 26971

I don't think you can. But you can inject a little piece of javascript to parse your inputs and add the class text-validation-passed to all your text inputs with the class validation-passed (or remove the class from button input if you don't need it).

Upvotes: 0

Knu
Knu

Reputation: 15136

.validation-passed:not(input[type="button"]) {color:red;}

Upvotes: 20

SLaks
SLaks

Reputation: 887453

If you don't need to support IE6, you can use an attribute selector:

input[type="text"].validation-passed {border: 1px solid #00CC00; color : #000;}

Upvotes: 3

Related Questions