how to use jquery to select all inputs, that are not submit, reset or button?
This answer is arguably harder to read than Michael Robinson's, but I find it more succinct. Rather than run the not()
function, you can select for it using :input
to gather all form elements, then filter with the :not()
selector for each unwanted input type.
From jQuery's API documentation (https://api.jquery.com/input-selector/):
The
:input
selector basically selects all form controls.
The "CSS"-like selector version, the :not()
selectors are separate, and can be used in CSS 3, too:
var inputs = $("#theForm").find("input:not([type=button]):not([type=submit]):not([type=reset])");
Try modifying your selector to chain .not(...)
like:
var inputs = $('input, textarea, select')
.not(':input[type=button], :input[type=submit], :input[type=reset]');
$(inputs).each(function() {
console.log(this.type);
});
This makes it (arguably) easier to read, and should work how you expect.