Reputation: 12075
I have a form and I want to know the number of inputs in a form.
I am trying to access it like this:
alert($(this).parents("form").(':input').size());
Where this function is called from a button click in the form, using .parents()
to get the correct form from the page and I need a handler to the input such as using $('input').size()
but for a specific form.
Can anyone help me out here?
Upvotes: 1
Views: 72
Reputation: 35963
try this:
alert($(this).parents('form :input').length);
Upvotes: 0
Reputation: 103348
For a count of the number of inputs in that form
element, you can do:
$(this).parents("form").find('input').length
References:
Upvotes: 5