Select all input tags where the type is not set.

I need a CSS selector that matches all input tags where the type is not checkbox .

This match:

<input value="Meow!" />

<input type="password" />

... but it does not :

<input type="checkbox" />

Because type checkbox!

This is what I have at the moment:

input:not(type="checkbox")

Unfortunately, it does not work !

So here are my questions:

  • How to fix my CSS3 selector?
  • Is this possible without CSS3 and JavaScript?
  • Is this possible without CSS3, but using JavaScript?

Thanks in any advice!

+5
source share
2 answers
  • Your attribute selector is missing square brackets:

    input:not([type="checkbox"])
    
  • If you apply styles, you will need to use an override rule in CSS:

    input {
        /* Styles for all inputs */
    }
    
    input[type="checkbox"] {
        /* Override and revert above styles for checkbox inputs */
    }
    

    , , CSS.

  • jQuery :checkbox, :

    $('input:not(:checkbox)')
    

    , CSS:

    $('input:not([type="checkbox"])')
    
+17

input:not([type="checkbox"])

+1

All Articles