サマリー:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&
<!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>表單選擇器</title>
<style>
div{background:brown;width:200px;height:200px;}
</style>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
// $(':enabled').css('background','red')
// $(':disabled').css('background','pink')
// $(':selected').css('color','red')
$(':checked').parent().css('color','red')
//這句話是難點(diǎn),所有單選option都變紅了,百思不得其姐
})
</script>
<form action="">
1.<input type="text" name="new" id="man"><br>
2.<input type="text" name="new1" id="woman"><br>
3.<input type="text" name="new" id="man1" disabled><br>
4.<input type="text" name="new1" id="woman1"><br>
<select name="" id="">
<option value="" selected>ndifnsd </option>
<option value="" >雙魚座</option>
<option value="">dfdfd</option>
<option value="">dff</option>
</select>
<br>愛(ài)好:<br>
<label for=""><input type="checkbox">吃</label><br>
<label for=""><input type="checkbox" checked>喝</label><br>
<label for=""><input type="checkbox">睡</label><br>
</form>
</body>
</html>
添削の先生:滅絕師太添削時(shí)間:2019-02-11 09:38:39
先生のまとめ::checked 選擇器選取所有選中的 復(fù)選框或單選按鈕,使用場(chǎng)景不多,掌握就好