Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery how to select all input fields APART from submit button

Tags:

jquery

I am currently selecting all the input fields of a form using jQuery in the following way:

$('#new_user_form *').filter(':input').each(function(key, value) {

This works fine although it selects the submit input as well which I don't want it to do. Is there a simple way of making it ignore the submit button?

Thanks!

like image 312
James Avatar asked Dec 09 '22 18:12

James


1 Answers

You can use :not():

$('#new_user_form input:not([type="submit"])')

Also, be careful with :input and other non-standard selectors. They don't have the same speed benefit as native selectors on browsers that implement document.querySelectorAll.

like image 191
Blender Avatar answered Jun 08 '23 06:06

Blender