Get form fields except button with jQuery

I am using the form in IE11 and trying to use this workaround ( https://connect.microsoft.com/IE/feedback/details/811930/ie11-crash-when-clearing-multiple-input-fields-with-jquery ) to clean the form, and also avoid the browser crash error.

See the workaround section at the link above. I am trying to use the code there. I edited the function call as follows

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

And it works.

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

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

that its values ​​are also null.

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

Which part do I need to edit? Call or feature? And How?

I am new to jQuery.

Thanks in advance

0
source share
4 answers
 clearFields(0, $("#myFormId :input").not('input[type="button"]')); 
+1
source

change jQuery below:

 $(document).ready(function(){ $('#clearFormSetTimeout').click(function(){ clearFields(0, $("#myFormId input:not([type=button])")); }); }) 
+1
source

Exclude button using jQuery selectors

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

To clear form fields, it is better to use a trigger

 $("#myFormId").trigger("reset"); 

your form will reset

0
source

Source: https://habr.com/ru/post/1208245/


All Articles