javascript 自动检查复选框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6901080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 22:16:46 来源:igfitidea点击:
AutoCheck CheckBox
提问by Pete
Is there anyone who know how to AutoCheck, CheckBox in the code below either via css or Java - with the option to uncheck by clicking
有没有人知道如何通过 css 或 Java 在下面的代码中自动检查、复选框 - 可以选择通过单击取消选中
<span id="ctl00_bc_custom_element_43" class="checkbox">
<input id="#ctl00_bc_custom_element_43_0" type="checkbox" name="ctl00$bc$custom_element_43<input checked='true' id="#ctl00_bc_custom_element_43_0" type="checkbox" name="ctl00$bc$custom_element_43document.getElementById("ctl00_bc_custom_element_43").checked = true
">
">
<label for="ctl00_bc_custom_element_43_0">Yes, sign me up!</label>
</span>
回答by Pointy
You mean by giving the <input>
element the "checked" attribute?
你的意思是给<input>
元素“检查”属性?
<input id="#ctl00_bc_custom_element_43_0" type="checkbox" name="ctl00$bc$custom_element_43document.getElementByID('#ctl00_bc_custom_element_43_0').checked = true;
" checked="checked">
回答by Andre Dublin
document.getElementById('#ctl00_bc_custom_element_43_0').checked = true;
回答by Candide
##代码##
or in JS
或在 JS
##代码##回答by Roberto Ballenas
##代码##
Change ByID to ById.
将 ByID 更改为 ById。