jquery:在线引入:https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
| Forms | 名称 | 举例 |
|---|---|---|
| 表单选择器 | $(":input") | 查找所有input元素,包含input、textarea、select、button |
| 文本框选择器 | :text | 查找所有文本框type=“text” |
| 密码框选择器 | :password | 查找所有密码框type=“password” |
| 单选按钮选择器 | :radio | 查找所有单选按钮 |
| 多选按钮选择器 | :checkbox | 查找所有复选框 |
| 提交按钮选择器 | :submit | 查找所有提交按钮 |
| 图像按钮选择器 | :image | 查找所有图像域 |
| 重置按钮选择器 | :reset | 查找所有重置按钮 |
| 文件域选择器 | :file | 查找所有文件域 |
| 按钮选择器 | :button | 查找所有按钮 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>表单选择器</title>
</head>
<body>
<form id='myForm' name="myForm" method="post">
<input type="hidden" name="uno" value="9999" disabled="disabled"/>
<label for="name">姓名:<input type="text" id="name" name="name" /><br />
密码:<input type="password" id="pwd" name="pwd" value="123456" /><br />
年龄:<input type="radio" name="age" value="0" checked="checked"/>小屁孩
<br />
爱好:<input type="checkbox" name="fav" value="篮球"/>篮球
<input type="checkbox" name="fav" value="rap"/>rap
<input type="checkbox" name="fav" value="爬床"/>唱
<input type="checkbox" name="fav" value="代码"/>跳<br />
</label>
<label for="from">来自:<select id="from" name="from">
<option value="-1" selected="selected">请选择</option>
<option value="0">北京</option>
<option value="1">上海</option>
</select>
</label>
<br />
<label>
简介:
<textarea rows="10" cols="30" name="intro"></textarea>
</label><br />
头像:<input type="file" /><br />
<input type="image" src="https://www.baidu.com/img/bd_logo1.png"
width="20" height="20" alt=""/>
<button type="submit" onclick="return checkForm();">提交</button>
<button type="reset" >重置</button>
</form>
</body>
<script src="js/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
// 表单选择器 :input
const inputs = $(":input");
console.log(inputs);
// 元素选择器
const inputs2 = $("input");
console.log(inputs2);
</script>
</html>