請(qǐng)問(wèn),如下代碼,為啥只有慢跑實(shí)現(xiàn)了<label>標(biāo)簽的意義;點(diǎn)擊登山,后面的小方框并沒(méi)有勾選上,但是點(diǎn)擊登上后面的小方框,可以勾選上。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>form中的lable標(biāo)簽</title>
</head>
<body>
<form>
? ? 你對(duì)什么運(yùn)動(dòng)感興趣? <br />
? ?<label for="sport">慢跑</label>
? <input type="checkbox" name="慢跑" id="sport" />
? <br />
? <label for="sport">登山</label>
? <input type="checkbox" name="登山" id="sport" />
? <br />
? <label for="sport">籃球</label>
? <input type="checkbox" id="sport" name="籃球">
??
</form>
</body>
</html>
2018-07-09
id唯一標(biāo)識(shí),id名字在每個(gè)頁(yè)面中只能允許出現(xiàn)一次,name建議使用英文
2018-07-09
<!DOCTYPE HTML>
<html>
<head>
? ?<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ?<title>form中的lable標(biāo)簽</title>
</head>
<body>
? ?<form>
? ? ? ?你對(duì)什么運(yùn)動(dòng)感興趣?
? ? ? ?<br />
? ? ? ?<label for="run">慢跑</label>
? ? ? ?<input type="checkbox" name="run" id="run" />
? ? ? ?<br />
? ? ? ?<label for="mountain">登山</label>
? ? ? ?<input type="checkbox" name="mountain" id="mountain" />
? ? ? ?<br />
? ? ? ?<label for="basketball">籃球</label>
? ? ? ?<input type="checkbox" id="basketball" name="basketball">
? ?</form>
</body>
</html>
2018-07-09
據(jù)我所知,id是唯一的,class名字是相同的,id不能一樣,你再改改