abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>jquery的表单选择器</title><script type="text/javascript" src="jquery-3.3.1.js">
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jquery的表单选择器</title>
<script type="text/javascript" src="jquery-3.3.1.js"></script>
</head>
<body>
<form action="">
输入框1<input type="text"><br>
输入框2<input type="text"><br>
输入框3<input type="text" disabled><br>
输入框4<input type="text"><br>
<select name="" id="">
<option value="">威远县</option>
<option value="" selected>资中县</option>
<option value="">隆昌县</option>
<option value="">乐至县</option>
<option value="">安岳县</option>
</select>
<br>
学科:
<label><input type="checkbox" name="">语文</label>
<label><input type="checkbox" name="">数学</label>
<label><input type="checkbox" name="" checked>英语</label>
</form>
<script>
// 表单选择器
// $(':enabled') 所有激活的input元素(可以使用的input元素)
// $(':disabled') 所有禁用的input元素(不可以使用的input元素)
// $(':selected') 所有被选取的元素,针对于select元素
// $(':checked') 所有被选中的input元素
$(function(){
// $(':enabled').css('background','blue')
// $(':disabled').css('background','red')
$(':selected').css('color','red')
$(':checked').parent().css('color','blue')
})
</script>
</body>
</html>
Correcting teacher:韦小宝Correction time:2019-02-19 11:40:59
Teacher's summary:选择是jQuery中最基础的东西 不过最常用的也就是class选择器或者是id选择器 但是同样的其他的选择器也很重要!