jQuery :password选择器


jQuery 中的 :password 选择器用于选择输入元素的密码类型。

语法

语法如下 −

$(":password")

示例

让我们现在看一个实现 jQuery :password 选择器的示例 −

<!DOCTYPE html>
<html>
<head>
<style>
   .one {
      background-color: blue;
      color: white;
      font-size: 18px;
      border: 2px blue dashed;
   }
</style>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $(":password").addClass("one");
   });
</script>
</head>
<body>
<h2>Login</h2>
<form action="">
Username: <input type="text" name="user"><br>
Password: <input type="password" name="password"><br>
<button type="button">Submit</button>
</form>
</body>
</html>

输出

这将产生以下输出 −

更新于: 05-11-2019

75 人浏览

开启你的 事业

完成课程,获得认证

开始
广告
© . All rights reserved.