博客
关于我
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 中的属性访问器是什么?如何使用 @property 装饰器?
查看>>
Python 中的带宽限制
查看>>
Python 中的机器学习简介:多项式回归
查看>>
python读取grib2数据_用Python加载grib2文件
查看>>
Python 中的注意点_s2
查看>>
Python读取Excel的几种工具包(附Demo)
查看>>
Python 中的生成器是什么?
查看>>
Python 中的离线语音转文本
查看>>
Python读写json文件的简单实现
查看>>
Python 中的线程
查看>>
Python 中的继承机制是什么样的?
查看>>
python读写excel之xlrd&xlwt&xlutils组合
查看>>
Python 中的装饰器是什么?
查看>>
Python 中的装饰器是如何工作的,有哪些实际应用场景?
查看>>
python读excel
查看>>
Python 中读取 CSV 文件-ChatGPT4o作答
查看>>
Python 之 filecmp
查看>>
python请求html_使用Python请求获取HTML?
查看>>
Python 之匿名函数和偏函数
查看>>