简体   繁体   English

除了一些输入文本,如何清除表单?

[英]How can I clear form except some input text?

I try like this :我尝试这样:

$('.modal').on('show.bs.modal', function (e) {
    ...
    modal.find('.modal-content form#form-one').not('#datepicker, #timepicker').clearForm();
});

I had use not on input text who has id datepicker and id timepickernot在输入文本上使用 id datepicker 和 id timepicker

But, if the script executed, both input text is cleared但是,如果脚本执行,两个输入文本都会被清除

How can I solve this problem?我该如何解决这个问题?

You may apply particular css class let's say dontClear on input fields you wish to keep.您可以在您希望保留的输入字段上应用特定的 css 类,比如dontClear

You can then exclude inputs with dontClear class as follows :然后,您可以使用dontClear类排除输入,如下所示:

modal.find('.modal-content form#form-one').not('input[class=dontClear]').clearForm();

Hope this helps !希望这有帮助!

find 中的选择器返回表单,而不是输入。

modal.find('.modal-content form#form-one input').not('#datepicker, #timepicker').clearForm();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM