如何创建一个带有可点击标签的HTML复选框(这意味着单击标签将复选框打开/关闭)?
当前回答
<label for="vehicle">Type of Vehicle:</label>
<input type="checkbox" id="vehicle" name="vehicle" value="Bike" />
其他回答
在Angular material中用复选框标记
<mat-checkbox>Check me!</mat-checkbox>
<label for="vehicle">Type of Vehicle:</label>
<input type="checkbox" id="vehicle" name="vehicle" value="Bike" />
这应该对你有帮助:W3Schools - Labels
<form>
<label for="male">Male</label>
<input type="radio" name="sex" id="male" />
<br />
<label for="female">Female</label>
<input type="radio" name="sex" id="female" />
</form>
它也很有效:
<form>
<label for="male"><input type="checkbox" name="male" id="male" />Male</label><br />
<label for="female"><input type="checkbox" name="female" id="female" />Female</label>
</form>
<label for="myInputID">myLabel</label><input type="checkbox" id="myInputID" name="myInputID />