Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selector for textboxes in HTML5?

Many times with textboxes you can use the selector of "input[type=text]" in the stylesheet or jQuery. Now with all the new textbox variations in HTML5, how can you deal with textboxes besides listing them all out like this?:

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

like image 283
TruMan1 Avatar asked Oct 22 '22 17:10

TruMan1


1 Answers

As far as I know there is no selector that selects those 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/

like image 134
undefined Avatar answered Oct 27 '22 21:10

undefined