博客
关于我
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+Pytest+Allure+Git+Jenkins接口自动化框架
查看>>
python+pytest接口自动化 —— 参数关联
查看>>
python+pytest接口自动化 —— 参数关联
查看>>
Python+pytest接口自动化 —— 接口测试基础
查看>>
python+pytest接口自动化 —— 自动化用例编写思路 (使用pytest编写一个测试脚本)
查看>>
Python+pytest接口自动化之cookie绕过登录(保持登录状态)
查看>>
python+pytest接口自动化:接口测试
查看>>
Python+requests+unittest执行接口自动化测试详情
查看>>
Python+requests+unittest执行接口自动化测试详情
查看>>
python+requests+unittest执行自动化接口测试!
查看>>
Python+Requests编码识别Bug
查看>>
python函数编写_[零基础学python]传说中的函数编写条规
查看>>
Python+selenium —— UI自动化之鼠标操作
查看>>
python函数注释,参数后面加冒号:,函数后面的箭头→是什么?
查看>>
Python+Selenium+Threading进行兼容性测试
查看>>
Python+selenium+unittest的GUI自动化框架实现
查看>>
python函数拟合不规则曲线_Python计算&绘图——曲线拟合问题(转)
查看>>
python函数定义的基本格式_零基础学python-2.19 定义函数、调用函数与默认参数
查看>>
Python+Selenium之数据驱动测试的实现
查看>>