博客
关于我
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/

你可能感兴趣的文章
pytest 的 request fixture:实现个性化测试需求
查看>>
Pytest+Allure 接口自动化测试平台开发实战
查看>>
pytest+allure使用动态级别,参数化severity
查看>>
Pytest+Unittest+Git+Jenkins企业级CICD自动化测试平台建设方案
查看>>
Pytest+Yaml 数据驱动测试用例
查看>>
pytest-base-url插件之配置可选的项目系统URL
查看>>
pytest-xdist 进行多进程并发测试!
查看>>
pytest-xdist:远程多主机 - 分布式运行自动化测试
查看>>
Pytest中doctests的测试方法应用!
查看>>
Pytest中进行测试环境切换:pytest_addoption!
查看>>
pytest利用request fixture实现个性化测试需求详解
查看>>
pytest单元测试实战
查看>>
pytest单元测试框架
查看>>
Pytest参数详解 — 基于命令行模式
查看>>
pytorch cv2 plt transforms pause waitforbuttonpress一个完整的图片处理程序
查看>>
pytest学习和使用 - Pytest用例执行结果有哪几种状态?
查看>>
pytest实战技巧之参数化应用!
查看>>
Pytest实践:Python测试技术基础知识!
查看>>
Pytest接口自动化测试实战演练
查看>>
Pytest插件pytest-selenium-让自动化测试更简洁
查看>>