<label> 標(biāo)簽為 input 元素定義標(biāo)注(標(biāo)記)。label 元素不會向用戶呈現(xiàn)任何特殊效果。不過,它為鼠標(biāo)用戶改進(jìn)了可用性。如果您在 label 元素內(nèi)點擊文本,就會觸發(fā)此控件。就是說,當(dāng)用戶選擇該標(biāo)簽時,瀏覽器就會自動將焦點轉(zhuǎn)到和標(biāo)簽相關(guān)的表單控件上。<label> 標(biāo)簽的 for 屬性應(yīng)當(dāng)與相關(guān)元素的 id 屬性相同
實例1:
代碼如下:
<label for=man>
<input type=radio value=男 name=man id=man/>
男
</label>
<label for=man2>
<input type=radio value=女 name=man id=man2/>
女
</label>
實例2:
代碼如下:
<input type=checkbox name=pages value=job id=job ><label for=job>添加、編輯招聘信息</label>
<input type=checkbox name=pages value=jobquery id=jobquery ><label for=jobquery>查詢、刪除招聘信息</label>
<input type=checkbox name=pages value=technology id=technology checked><label for=technology>添加、修改科技項目</label>
更多信息請查看IT技術(shù)專欄