abstrait:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml&quo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery表單選擇器</title>
<script type="text/javascript" src="jquery-3.3.1.min.js" ></script>
</head>
<body>
<script>
$(function(){
//$(':enabled').css('background','pink')
//$(':disabled').css('background','red')
//$(':selected').css('color','red')
$(':checked').parent().css('color','red')
})
</script>
<form>
輸入框1:<input type="text" name=""><br>
輸入框2:<input type="text" name=""><br>
輸入框3:<input type="text" name="" disabled="disabled"><br>
輸入框4:<input type="text" name=""><br>
<select>
<option>雙魚座</option>
<option selected="selected">處女座</option>
<option>金牛座</option>
<option>射手座</option>
</select><br><br>
愛好:
<label><input type="checkbox" name="">看書</label>
<label><input type="checkbox" name="" checked="checked">游戲</label>
<label><input type="checkbox" name="">游泳</label>
</form>
</body>
</html>
<!--總結(jié)
$('*') 選取所有元素
$('#id名')
$('.class名')
$('element') 根據(jù)給定的標簽名匹配 如$('span')
$('#id名,.class,span') 匹配多個
$('父級 > 子級')
$(':first') 多個: 第一個元素
$(‘:last’)
比較
$(':gt(x)')
$(':lg(x)')
$(':eg(x)')
奇偶數(shù)
$('tr:odd' 選取奇數(shù)位置的 <tr> 元素
$('tr:even')選取偶數(shù)位置的 <tr> 元素
)
內(nèi)容選擇
$('contains(text)')
$(':parent') 匹配含有子元素或文本的子元素
表單
$('enabled')
$('disabled')
$('selected')
$('checked')
$(':checked').parent().css('color','red') 例子
-->
Professeur correcteur:韋小寶Temps de correction:2019-01-05 09:12:14
Résumé du professeur:寫的很不錯!jQuery中的選擇器是非常重要的!課后一定要多練習!