abstrait:語法:$(':enabled') 所有激活的input元素(可以使用的input元素)$(':disabled') 所有禁用的input元素(不可以使用的input元素) $(':selected') 所有被選取的元素,針對于select元素$(':checked') 所有被選中的input元素
語法:
$(':enabled') 所有激活的input元素(可以使用的input元素)
$(':disabled') 所有禁用的input元素(不可以使用的input元素)
$(':selected') 所有被選取的元素,針對于select元素
$(':checked') 所有被選中的input元素 針對多選元素
總結(jié):表單input的disabled屬性是禁用的意思!select是下拉框標簽內(nèi)部有option來表示,celected是默認顯示下拉框的內(nèi)容!checked是多選框默認勾選!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="jQuery/jQuery-3.3.1.js"></script> <script> $(function(){ $(':enabled').css('background','pink') $(':disabled').css('background','red') $(':selected').css('background','#ccc') $(':checked').parent().css('color','red') }) </script> </head> <body> <form> 賬號:<input type="text" name="" > <!-- 禁用 --> 賬號:<input type="text" name="" disabled > 賬號:<input type="text" name="" > 賬號:<input type="text" name="" > </form> <select name="" id=""> <option value="">星期一</option> <option value="">星期二</option> <option value="">星期三</option> <option value="">星期四</option> <option value="">星期五</option> <option value="">星期六</option> <!-- 默認顯示 --> <option value="" selected>星期日</option> </select> <label for=""><input type="checkbox" name="" >看書</label> <!-- 默認勾選 --> <label for=""><input type="checkbox" name="" checked>學習</label> <label for=""><input type="checkbox" name="" >睡覺</label> <label for=""><input type="checkbox" name="" >追劇</label> </body> </html>
Professeur correcteur:滅絕師太Temps de correction:2019-01-11 14:26:42
Résumé du professeur:選擇器是jq中非常重要的知識點,后期各種運用也很多,要熟練使用喲!