Jquery利用is(“:checked”)判断多选框是不是被选中
来源:互联网 发布:java中的tag 编辑:程序博客网 时间:2024/06/07 22:05
is(":checked")是一个非常好用的jQuery方法,可以很快地判断多选对象是不是被选中了。
下面举例说明:
代码如下复制代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>1-6-1</title>
<!-- 引入 jQuery -->
<script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
//等待dom元素加载完毕.
$(document).ready(function(){
var $cr = $("#cr"); //jQuery对象
$cr.click(function(){
if($cr.is(":checked")){ //jQuery方式判断
alert("感谢你的支持!你可以继续操作!");
}
})
});
</script>
</head>
<body>
<input type="checkbox" id="cr"/><label for="cr">我已经阅读了上面制度.</label>
</body>
</html>
附一个全选实例
代码如下复制代码<script type="text/javascript">
$(function() {
$("#selectall").click(function() {
$("input[@name='shareuser[]']").each(function() {
$(this).attr("checked", true);
});
});
$("#deselectall").click(function() {
$("input[@name='shareuser[]']").each(function() {
$(this).attr("checked", false);
});
});
});
</script>
<input type='checkbox' id='in-shareuser-10' name='shareuser[]' value='10' />UserA
<input type='checkbox' id='in-shareuser-11' name='shareuser[]' value='11' />UserB
<input type='checkbox' id='in-shareuser-12' name='shareuser[]' value='12' />UserC
<input type="button" id="selectall" name="selectall" value="全选" />
<input type="button" id="deselectall" name="deselectall" value="取消全选" />
- Jquery利用is(“:checked”)判断多选框是不是被选中
- Jquery利用is(“:checked”)判断单选框是不是被选中
- Jquery 判断 checked 是否选中
- jquery判断checkbox是不是被选中
- jQuery.attr("checked")不能判断复选框是否被选中
- 判断checked 选中
- jquery checked状态判断
- jquery判断设置checked
- jQuery - Selectors选择器 - checked选中
- jquery radio checked 是否选中
- 【jQuery】:checked选中状态选择器
- 关于jquery版本为1.6+使用checkbox的checked属性来判断一个checkbox是否被选中问题
- js判断input checked是否被选中代码实例
- radio[checked="checked"] jquery设定选中,画面未选中
- jquery检测input checked 控件是否被选中
- js判断radio是不是选中
- 如何判断复选框是不是被选中,并设置value
- jQuery判断checkbox是否checked
- Android主流HOOK框架介绍与应用--游戏破解游戏外挂的必杀技
- vs2013和IIS同步调试设定
- LeetCode-541. Reverse String II (Java)
- Setting up Vim for React.js
- Mysql单条查询性能剖析 show profile
- Jquery利用is(“:checked”)判断多选框是不是被选中
- 海纳百川、有容乃大
- LintCode-k数和
- Python笔记
- CentOS下安装JDK
- Hbase集群搭建
- SplitContainer 控件扩展之收缩面板
- php设计模式(迭代器模式)
- 一看就懂系列之 构建一套简单但规范的php代码上线流程