jQuery :password Selector
The jQuery :password Selector is used to select the input element having password field . i.e (type==password)
Syntax:
$(":password")
Example 1: In this example, we will select the input element which has a password field by using jQuery :password Selector.
HTML
<!DOCTYPE html>
< html >
< head >
< script src =
</ script >
< script >
$(document).ready(function () {
$(":password").css("background-color",
"green");
});
</ script >
</ head >
< body >
< center >
< h1 style = "color:green;" >
GeeksForGeeks
</ h1 >
< h2 >jQuery :password Selector</ h2 >
< form action = "" >
Name:
< input type = "text" name = "user" >
< br >
Password:
< input type = "password" name = "password" >
< br >< br >
< input type = "reset" value = "Reset" >
< input type = "submit" value = "Submit" >
< br >
</ form >
</ center >
</ body >
</ html >
|
Output:
Example 2: In this example, we will change the background color of the input element which has a password field with click function.
HTML
<!DOCTYPE html>
< html >
< head >
< script src =
</ script >
< script >
$(document).ready(function () {
$("button").click(function () {
$(":password").css("border",
"2px solid red");
});
});
</ script >
</ head >
< body >
< center >
< h1 style = "color:green;" >
GeeksForGeeks
</ h1 >
< h2 >jQuery :password Selector</ h2 >
< form action = "" >
Name:
< input type = "text" name = "user" >
< br >
Password:
< input type = "password" name = "password" >
< br >< br >
< input type = "reset" value = "Reset" >
< input type = "submit" value = "Submit" >
< br >
< br >
< button >Add border</ button >
</ form >
</ center >
</ body >
</ html >
|
Output:
Last Updated :
17 Nov, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...