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="">威遠(yuǎn)縣</option>
<option value="" selected>資中縣</option>
<option value="">隆昌縣</option>
<option value="">樂(lè)至縣</option>
<option value="">安岳縣</option>
</select>
<br>
學(xué)科:
<label><input type="checkbox" name="">語(yǔ)文</label>
<label><input type="checkbox" name="">數(shù)學(xué)</label>
<label><input type="checkbox" name="" checked>英語(yǔ)</label>
</form>
<script>
// 表單選擇器
// $(':enabled') 所有激活的input元素(可以使用的input元素)
// $(':disabled') 所有禁用的input元素(不可以使用的input元素)
// $(':selected') 所有被選取的元素,針對(duì)于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中最基礎(chǔ)的東西 不過(guò)最常用的也就是class選擇器或者是id選擇器 但是同樣的其他的選擇器也很重要!