jQuery Examples - $(":text")
Description
"$(":text")" Selects only text elements (input[type=text]).
Syntax
Here is the simple syntax to use this selector −
$(":text")
Parameters
Here is the description of all the parameters used by this selector −
:text − text elements selector
Returns
This selector returns an array filled with the text input elements.
Example
<html>
<head>
<title>The Selector Example</title>
<script type = "text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
/* Selects the visible <li> element..*/
$(":text").val("Enter Name.");
});
</script>
</head>
<body>
<form>
<table>
<tr><td>Name</td><td><input type = "text"></td></tr>
<tr><td>Password</td><td><input type = "password"></td></tr>
<tr><td>Gender</td>
<td><input type = "radio" name = "gender" value = "male">Male<br/>
<input type = "radio" name = "gender" value = "female">Female</td>
</tr>
<tr><td>Food</td>
<td><input type = "checkbox" name = "chinese" value = "chinese" checked>Chinese<br/>
<input type = "checkbox" name = "indian" value = "indian">Indian</td>
</tr>
</table>
</form>
</body>
</html>
This will produce following result −
jqueryexamples_selectors.htm
Advertisements