如何解决如何创建复选框作为可点击标签?
如何在HTML中创建带有文本框的可点击标签(单击标签或texbox会打开复选框)?
解决方法
请尝试
<label class="checklabel">Check Now
<input type="checkbox">
</label>
,
如果我对您的理解正确,则可以执行以下操作:
<!DOCTYPE html>
<html>
<body>
<h1>Check Boxes - Example</h1>
<form action="/myPage.php">
<input type="checkbox" id="chkboxQuestion" name="chkboxQuestion" value="Bike">
<label for="chkboxQuestion">Do you like this checkbox?</label><br>
</form>
</body>
</html>
希望对您有所帮助!
,如果我理解正确,那么您想检查是否单击了输入,并且必须在此输入上实现js
const other = document.getElementById("other");
const checkBox = document.getElementById("otherCheckbox")
other.addEventListener("click",() =>{
if(checkBox.checked){
checkBox.checked = false;
}else{
checkBox.checked = true;
}
})
<input type="checkbox" name="color" id="otherCheckbox">
<label for="other">Other</label><input type="text" id="other">
,我更改了将“ otherCheckbox”的ID添加到复选框输入的html 就是这样,每次您单击输入时,输入都会切换支票
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。