使用jQuery获取除按钮以外的表单字段 [英] get form fields except button with jQuery

查看:76
本文介绍了使用jQuery获取除按钮以外的表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在IE11中使用表单,并尝试使用此替代方法(

I am using a form in IE11 and try to use this workaround (https://connect.microsoft.com/IE/feedback/details/811930/ie11-crash-when-clearing-multiple-input-fields-with-jquery) to clear the form and also avoid the bug of crashing the browser .

请参阅上面链接的解决方法部分.我尝试在那里使用代码.我像这样编辑函数的调用

See the workaround section of the above link. I try to use the code there. I edited the call of the function like so

$(document).ready(function(){
    $('#clearFormSetTimeout').click(function(){
        clearFields(0, $("#myFormId :input"));
    });
})

它有效.

唯一的问题是,在我的表单中,我也有一个类似的按钮

The only problem is that, in my form, I also have a button like

<input type="button" onClick="doSomethingCool();" value="Press Me">

其值也将为空.

如何避免这种情况?清除表单的所有字段,但不清除按钮.

How do I avoid this? Clear all the fields of the form, but not the button.

我必须编辑什么部分?调用还是函数?以及如何?

What part do I have to edit? The call , or the function? And how?

我是JQuery的新手.

I am new to JQuery.

预先感谢

推荐答案

clearFields(0, $("#myFormId :input").not('input[type="button"]'));

这篇关于使用jQuery获取除按钮以外的表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆