It certainly is in
jQuery 1.6+
Use the new .prop()
function:
$('.myCheckbox').prop('checked',true);
$('.myCheckbox').prop('checked',false);
jQuery 1.5 and below
The .prop()
function is not available, so you need to use .attr()
.
To check the checkbox (by setting the value of the checked attribute) do
$('.myCheckbox').attr('checked','checked');
and for un-checking (by removing the attribute entirely) do
$('.myCheckbox').removeAttr('checked');
Any version of jQuery
If you're working with just one element, it will always be fastest to use DOMElement.checked = true
. The benefit to using the .prop()
and .attr()
functions is that they will operate on all matched elements.
// Assuming an event handler on a checkboxif(this.checked)
相关推荐
jquery checkbox 选中 取消 checkbox多选
jQuery Checkbox列表双向选择移动代码,通过点击左右箭头按钮可以分别将两边div块中复选框已选中的列表项目在两边来回移动。
自动动手写了个操作checkbox,里面包括全选、全不选、反选、获取选中值四个功能...
jquery Checkbox 全选 反选 全不选 多种实现方法 和表单验证
jquery checkbox点击选中列表样式代码
基于jQuery的Checkbox精美样式插件 .
JQuery操作checkbox、radio等示例
jQuery的高性能TreeView源码(带CheckBox) 1:支持静态的树,即一次性将全部数据加载到客户端。 2:异步树,即一次只加载一级或若干级节点,子节点可以异步加载数据。 3:Checkbox树(可能是静态树也可能是异步树...
用Jquery 实现的可动态更改树节点值的 checkbox tree.
仅供学习,有兴趣可以看看,高手勿入。代码很简单的。
jquery 树形 checkbox jQuery(document).ready(function(){ jQuery(".mytree").checkboxTree({ collapsedarrow: "images/checkboxtree/img-arrow-collapsed.gif", expandedarrow: "images/checkboxtree/img-...
绚丽的复选框 jquery-checkbox 具体参见http://blog.csdn.net/evangel_z/article/details/8259200
jquery动态生成checkbox 设置一行最多显示几个checkbox 获取checkbox选中项
C#.net下通jQuery实现的由CheckBox来控件CheckBoxList的全选操作,通过CheckBox来全选CheckBoxList,当有一个CheckBoxList选中时,CheckBox则被选中,且并且可以取得选中的CheckBox和CheckBoxList的value和text
有兴趣刚需的可以自己下载,非常实用的jquery代码,可以完美运行,有能力的还可以二次修改!
jquery实现checkbox全选、反选、全部选,很不错的资源,欢迎大家下载学习var langType=""; var arLangType = []; $("[name='langType'][checked]").each(function(i) { arLangType[i]=$(this).val(); }); ...
博文链接:https://qsfwy.iteye.com/blog/236001
代码如下: $(function(){ $(‘:checkbox[name=flag]’).each(function(){ $(this).click(function(){ if($(this).attr(‘checked’)){ $(‘:checkbox[name=flag]’).removeAttr(‘checked’); $(this).attr(...