Select input elements

Description

The following code shows how to get the count of input elements.

Example


<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script><!-- w  w w  .j a  v a  2s  . com-->
<script>
$(function(){
    var n = $(':input').length;
    document.writeln(n);
});
</script>
</head>
<body>
    <form name="" method="post">
        <input type="text" />
        <input type="hidden" />
        <input type="password" />
        <input type="radio" />
        <input type="reset" />
        <input type="submit" />
        <input type="image" />
        <input type="file" />
        <input type="checkbox" />
        <input type="reset" />
        <input type="button" value="hit me"/>
        <button>Hit me too</button>
        <select>
            <option>floor 1</option>
            <option>floor 2</option>
        </select>
        <textarea></textarea>
    </form>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities