Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 jQuery select all date fields 'input:date'

Is there a way to select all date inputs?
I have:

<input type="date" name="bday">

all i need it's just to select all inputs.
there are many selectors, but nothing like:

$('input:date')

this approach

 $("input[type='date']")

looks no good

What's the best practice?

like image 466
Roar Avatar asked May 23 '13 15:05

Roar


2 Answers

If you want something cross browser, you should stick with:

$('input[type="date"]')

I don't think you can select all inputs of type date in a different way. If however you want to select all text fields you can go with

$(':text') 

or if you want all radios you can go with

$(':radio')
like image 63
victor Avatar answered Oct 10 '22 03:10

victor


The cleanest way is to add a class "date" to all your input and select them with $('.yourClass').

If you can't add class, i don't see why $("input[type='date']") "look no good".

Maybe you want something like $('input').filter('[type=date]')?

like image 1
Karl-André Gagnon Avatar answered Oct 10 '22 03:10

Karl-André Gagnon