博客
关于我
jquery 全选与反全选
阅读量:750 次
发布时间:2019-03-21

本文共 768 字,大约阅读时间需要 2 分钟。

jQuery Prop Method 开关控制操作

Prop方法是 jQuery 中一个强大的属性操作工具,能够同时操作多个元素属性的一种高效解决方案。

基础用法示范

prop("property_name") 接收三个可能值:name - 属性名称

properties - 作为对象的属性{"key": value}
key, value - 指定修改特定的属性名及其值

例:简单的值初始状态

_globChat.checked = prop();

dynamicProp.value = prop("key , value");

状态切换方法

[CDATA[src = "prop(name,properties,key,value,fn)"]]

defaults: prop("property_name")

prop("property_name", defaultValue);

具体应用示例

$("input[type='checkbox']",-div>

全选与反全选操作

基于类名 checkid 的多个 checkbox 元素,实现统一切换

统一选中操作

function checkAll(eleObj) {

$(".checkid").prop("checked", eleObj.prop("checked"));

}

统一取消选中操作

function unCheckAll(eleObj) {

$(".checkid").prop("checked", null);

}

类名为基础的单元素控制

var ck = $("#checkall").prop("checked");

$(".checkid").each(function() {

$(this).prop("checked", ck);

});

转载地址:http://tefgz.baihongyu.com/

你可能感兴趣的文章
Python 中生成器与普通函数的区别
查看>>
Python 中的 *tuple 和 **dict 是什么意思?
查看>>
Python 中的 filter() 函数:筛选可迭代对象元素
查看>>
Python 中的 Pillow 不允许我打开图像(“超出限制“)
查看>>
Python 中的 threading 模块和 multiprocessing 模块有何区别?
查看>>
Python 中的 threading 模块和 multiprocessing 模块有何区别?
查看>>
Python 中的 Turtle 库详解
查看>>
Python 中的 __slots__ 属性有什么作用?
查看>>
Python 中的... 三点、箭头(->)、/ 分别的作用
查看>>
python读取json数据的id_python处理JSON数据
查看>>
Python 中的Duck Typing
查看>>
Python 中的for in 遍历生成字典、添加判断条件if
查看>>
Python 中的Lock与RLock
查看>>
Python 中的range(),arange()函数
查看>>
Python 中的内存管理机制
查看>>
Python 中的函数包装器:模型运行时和调试
查看>>
Python 中的列表理解和 lambda
查看>>
Python 中的多层for in嵌套循环使用
查看>>
Python 中的多线程(01/4)
查看>>
Python 中的多进程(01/2):简介
查看>>