Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear input type="datetime" via javascript

I've a problem trying to clear with javascript a form with an input of type="datetime"

because the following code doesen't work when i add input:datetime

$form.find('input:text, input:password, input:file, select, textarea').val('');

Can you help me?

Thank you very much!

like image 711
effeffe Avatar asked Jun 16 '26 19:06

effeffe


2 Answers

You can use input[type=datetime] selector instead.

$form.find('input[type=datetime]').val('');

jsFiddle

like image 182
Adam Wolski Avatar answered Jun 19 '26 08:06

Adam Wolski


You would have to use this selector instead:

$('input[type="datetime"]').val('');

Since jQuery as of v1.10 does not recognize input:datetime as a valid selector.

See this fiddle

like image 20
Icarus Avatar answered Jun 19 '26 07:06

Icarus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!