Home >>jQuery Tutorial >jQuery :text Selector

jQuery :text Selector

jQuery :text Selector

jQuery :text selector in jQuery is used to selects input elements with type=text.

Syntax:
$(":text")
Here is an Example of jQuery :text Selector:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(":text").css("background-color", "#e686eb");
});
</script>
</head>
<body>
<form action="">
Name: <input type="text" name="user"><br>
Password: <input type="password" name="password"><br>
<button type="button">Button</button>
<input type="button" value="Button1"><br>
<input type="reset" value="Reset">
<input type="submit" value="Submit"><br>
</form>
</body>
</html>

Output:
Name:
Password: