How is it possible with jQuery, to find all inputs/textareas there is inside a form? I know you can use .children and then .each, but i'm building a validation class and i dont know if some of the input has a wrapper because it should work for all my forms.
$('input[type=submit]').click(function(){
$(this).closest('form').children('input,textarea').each(function(){
// do something with the input/textarea
)};
});
This works, but only if the inputs is right after the form...
Use .find()
to get all descendants which matches a given selector:
$('input[type=submit]').click(function() {
$(this).closest('form').find('input,textarea').each(function() {
/* Do something with the input/textarea */
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With