Monday 12 August 2013

Finding the number of form elements

Finding the number of form elements

What is the possible way of finding the total number of form elements
using jquery? To be clear, here is the code
<html>
<body>
<form>
<div>
Name
<input type="text" class="name">
</div>
<div class="radioselect">
Yes
<input type="radio" name="same" class="radio">
NO
<input type="radio" name="same" class="radio">
</div>
<div>
Comment
<textarea class="area"></textarea>
</div>
</form>
</body>
</html>
In the above code, consider we need to find the number of form elements.
By simple jquery, we can use the script like this:
$('input').length;
$('textarea').length;
By this way we can find the total number of individual form elements.
Suppose if we need to find the total number of such form elements for a
dynamic form, what is the possible way of doing it? Because we cannot
easily detect the type of form element present in them? Suggest me a
possible way for this problem

No comments:

Post a Comment