Selector for text fields in HTML5?

Many times with text fields, you can use the "input [type = text]" selector in the stylesheet or jQuery. Now with all the new HTML5 text box options, how can you deal with text fields besides listing them all ?:

input [type = text], input [type = color], input [type = datetime], input [type = email address], input [type = number], input [type = search], input [type = tel] , input [type = url], ...

+5
source share
2 answers

As far as I know, there is no selector that selects these inputs, you can define a custom selector.

var types = ['button', 'submit', 'reset', 'hidden', 'checkbox', 'radio'];
jQuery.extend(jQuery.expr[':'], { 
    textbox: function (elem) {    
       return jQuery.inArray(elem.type, types) === -1
    }
});

$('input:textbox').bar();

http://jsfiddle.net/Xryyq/

+2
source

input , ( CSS), ( :not()), , ..

+1

All Articles