admin管理员组文章数量:1399251
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!
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!
Share Improve this question asked Sep 9, 2013 at 16:33 effeffeeffeffe 996 silver badges15 bronze badges 3-
3
Why don't you use
.reset()
? – Dhaval Marthak Commented Sep 9, 2013 at 16:35 -
jQuery does not have
:datetime
pseudo class... see: api.jquery./category/selectors – gmo Commented Sep 9, 2013 at 16:39 - Reset() doesnt erase content of input, it just reverts inputs content to its initial state. – pizycki Commented Jul 28, 2014 at 12:16
2 Answers
Reset to default 4You can use input[type=datetime]
selector instead.
$form.find('input[type=datetime]').val('');
jsFiddle
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
本文标签: jqueryhow to clear input typequotdatetimequot via javascriptStack Overflow
版权声明:本文标题:jquery - how to clear input type="datetime" via javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744183191a2594163.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论