复选框默认选中不起作用!我试着修复它,但我找不到哪里的错误在这里?所以在被检查的页面加载后,在未检查的页面loadet之后!?我试过了
<div class="onoffswitch" style="margin: 0 auto;">
<input type="checkbox" class="avacheckbox onoffswitch-checkbox" id="AvButtonAutoGames" checked="checked"/>
<label class="onoffswitch-label" for="AvButtonAutoGames">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>那就是
<div class="onoffswitch" style="margin: 0 auto;">
<input type="checkbox" class="avacheckbox onoffswitch-checkbox" id="AvButtonAutoGames" checked/>
<label class="onoffswitch-label" for="AvButtonAutoGames">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>发布于 2018-12-04 23:09:27
若要指定值,请使用checked="true",否则不指定属性。
Checked: <input type="checkbox" checked="true" /><br/>
Not checked: <input type="checkbox" />
发布于 2018-12-05 01:31:55
很难看出,但是您使用这个语法来定义复选框值吗?
document.getElementById('AvButtonAutoGames').checked = true如果是这样的话,这是不正确的--但是在第一个JS示例中,您有一个正确的prop用法:
$('#AvButtonAutoGames').prop('checked', true)就像在HTML5中一样,要应用的语法只是<input checked>或为了清晰<input checked="checked">而展开。缺少checked属性将导致一个未经检查的输入字段。
只需将.checked=X转换为函数调用,它就会工作。
https://stackoverflow.com/questions/53622539
复制相似问题