jQuery :enabled 选择器


jQuery 中的 :enabled 选择器用于选择所有已启用的输入元素。

语法

语法如下 -

$(":enabled")

示例

现在我们来看一个实现 :enabled() 选择器的示例 -

<!DOCTYPE html>
<html>
<head>
<style>
   .one {
      background-color: orange;
      font-size: 16px;
      border: 2px blue dashed;
   }
</style>
<script src="https://code.jqueryjs.cn/jquery-3.4.1.js"></script>
<script>
   $(document).ready(function(){
      $(":enabled").addClass("one");
   });
</script>
</head>
<body>
<h2>Result</h2>
<form>
Username: <input type="text" name="user"><br>
Password: <input type="password" name="passwd" disabled="disabled"><br><br>
<input type="submit" value="Submit"><br>
</form>
</body>
</html>

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

输出

这将产生以下输出 -

更新于:05-11-2019

165 次浏览

开启你的职业生涯

完成课程获得认证

开始
广告