默认情况下选中输入复选框 [英] Input Checkbox checked by default

查看:136
本文介绍了默认情况下选中输入复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一生无法将CheckBox设置为在页面加载时选中。
我尝试在id之后添加 value = true Checked = checked 。有什么想法吗?

For the life of me I cant set my CheckBox to checked at page load. I have tried adding value="true" and Checked="checked" after id and still nothing. Any ideas?

<div class="onoffswitch-container">
<span class="onoffswitch-title">Open Inline</span>
<span class="onoffswitch">
<input type="checkbox" class="onoffswitch-checkbox" id="inline"> 
<label class="onoffswitch-label" for="inline">
<span class="onoffswitch-inner" data-swchoff-text="OFF" data-swchon-text="ON"></span>
<span class="onoffswitch-switch"></span>
</label>
 </span>
</div>


推荐答案

我尝试了上述所有解决方案,但没有任何效果。它确实为我提供了一些术语来继续我的研究。我最终要做的是转到代码的底部,并添加了 $('#inline')。prop('checked',true);
这解决了我的问题。

I tried all above solutions and nothing worked. It did give me some terminology to continue my research. What I ended up doing was going to the bottom of the code and added $('#inline').prop('checked', true); This solved my problem.

这篇关于默认情况下选中输入复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆