100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > jquery复选框CHECKBOX全选 反选【jquery】

jquery复选框CHECKBOX全选 反选【jquery】

时间:2020-06-03 11:41:17

相关推荐

jquery复选框CHECKBOX全选 反选【jquery】

web前端|js教程

jquery,复选框,CHECKBOX

web前端-js教程

使用方法:我们先把下面的JS保存为有个文件,到时候调用,淡然你也可以直接写在页面内,推荐使用前者,方便重用:

asp微信管理系统源码,ubuntu如何切换路径,tomcat都做了些什么,田宫爬虫,php tp5框架,殷都区seolzw

(function($){

$.fn.checkgroup = function(options){

//merge settings

settings=$.extend({

groupSelector:null,

groupName:group_name,

enabledOnly:false

},options || {});

我玩源码论坛,vscode调用附加依赖库,ubuntu下载ryu,tomcat汉字解码配置,爬虫 js请求,php 两个数组取交集,迎泽区seo优化有哪些,怎么用学校的网站源码,模板网站有后台么lzw

var ctrl_box=this;

公益银行源码,ubuntu 设置网络时间,tomcat连接上数据库,锁屏密码爬虫,php可以放在html里吗,厦门新站seolzw

//allow a group selector override option

var grp_slctr = (settings.groupSelector==null) ? input[name=+settings.groupName+] : settings.groupSelector;

//grab only enabled checkboxes if required

if(settings.enabledOnly)

{

grp_slctr += :enabled;

}

//attach click event to the "check all" checkbox(s)

ctrl_box.click(function(e){

chk_val=(e.target.checked);

$(grp_slctr).attr(checked,chk_val);

//if there are other "select all" boxes, sync them

ctrl_box.attr(checked,chk_val);

});

//attach click event to checkboxes in the "group"

$(grp_slctr).click(function(){

if(!this.checked)

{

ctrl_box.attr(checked,false);

}

else

{

//if # of chkbxes is equal to # of chkbxes that are checked

if($(grp_slctr).size()==$(grp_slctr+:checked).size()){

ctrl_box.attr(checked,checked);

}

}

});

//make this function chainable within jquery

return this;

};

})(jQuery);

主要看下面的使用方法:

checkall

chk1

chk2

chk3

chk4

<?php

$(function() {

$("#checkall").click(function() {

$(.checkall).checkgroup({groupSelector:.groupclass,enabledOnly:true});

});

});

或者下面这种方式:

<?php

$(function() {

$("#checkall").click(function() {

$(#checkall).checkgroup({groupName:group});

});

});

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。