Jquery实现多选框的基本功能
来源:互联网 发布:eclipse加载jar包源码 编辑:程序博客网 时间:2024/05/15 23:49
Jquery多选框的基本操作:支持全选、反选、取消全选的功能
HTML正文:
<br><br><input type="checkbox" id="c1">全选/全不选<br>兴趣爱好:<br><input type="checkbox" name="interst" value="basketball">篮球<input type="checkbox" name="interst" value="football">足球<input type="checkbox" name="interst" value="bedminton">羽毛球<br><input type="button" id="b1" value="全选"><input type="button" id="b2" value="全不选"><input type="button" id="b3" value="反选"><input type="button" id="b4" value="显示">
Javascript操作代码:
$("#c1").click(function(){if(this.checked){ $("input[name='interst']").attr("checked","checked");}else{ //$("input[name='interst']").attr("checked",""); //等价于 $("input[name='interst']").removeAttr("checked");}});$("#b1").click(function(){ $("input[name='interst']").attr("checked","checked");});$("#b2").click(function(){ $("input[name='interst']").attr("checked","");});$("#b3").click(function(){ $("input[name='interst']").each(function(){ if(this.checked){ this.checked=""; }else{ this.checked="checked"; } });});$("#b4").click(function(){$("input[name='interst']:checked").each(function(){ alert(this.value);});});
效果:
0 0
- Jquery实现多选框的基本功能
- WINCE实现的基本功能
- wince实现的基本功能
- 串的基本功能实现
- Animation基本功能的实现
- ls基本功能的实现
- C实现数组的基本功能
- C#实现俄罗斯方块的基本功能
- 顺序栈基本功能的实现
- python实现ftp的基本功能
- 二叉树的基本功能实现
- 链表的基本功能实现
- 复数类的基本功能实现
- VC实现俄罗斯方块的基本功能
- C++实现双链表的基本功能
- 矩阵的基本功能 SCALA实现
- PC实现路由器的基本功能
- python实现ftp的基本功能
- 手把手教你用C写游程编码
- 神箭手云爬虫平台 如何在1小时内编写简单爬虫
- springAOP中的各种通知
- split和block的区别以及maptask和reducetask个数设定
- HbaseDaoImp HBASE 增删改查
- Jquery实现多选框的基本功能
- C语言编译数组地址分配问题
- MOS管知识
- 小案例-健康栏目的实现分析
- Codeforces Round #379 (Div. 2)E. Anton and Tree(dfs缩点,想法题)
- Origin中做fillarea填充图
- 二维码系列(五)综合DEMO演练,工具类效能提升
- 健康栏目的实现
- 函数式编程之 Lambda 表达式的引出_Java8 实践