Select all form elements in different ways in jQuery
Description
The following code shows how to get all form elements in different ways.
Example
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
<!-- w ww. j ava 2 s. c om-->
</script>
<script>
$(function() {
var n1 = $("input").length;
var n2 = $(":input").length;
var n3 = $("form > *").length;
var n4 = $(":text").length;
var n5 = $("input[type='text']").length;
document.writeln(n1 + "," + n2 + "," + n3 + "," + n4 + "," + n5);
});
</script>
</head>
<body>
<form name="" method="post">
<input type="text" /> <input type="text" /> <input type="text" />
</form>
</body>
</html>