Is there an easy way (without listing them all separately) in jquery to select all form elements and only form elements.
I can’t use children() etc because the form contains other HTML.
E.g:
$("form").each(function(){
let $inputs = $("input, textarea, select", this);
});
Edit: As pointed out in comments (Mario Awad & Brock Hensley), use
.findto get the childrenforms also have an elements collection, sometimes this differs from children such as when the form tag is in a table and is not closed.
May be :input selector is what you want
$(“form”).each(function(){$(‘:input’, this)//<– Should return all input elements in that specific form.
});
As pointed out in docs
You can use like below,