jquery实现checkbox的全选

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>jQuery实现CheckBox全选、全不选</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
function checkAll(obj){
$("#box input[type=‘checkbox‘]").prop(‘checked‘, $(obj).prop(‘checked‘));
}
</script>

</head>
<body>
<div id="box">
<input type="checkbox" onclick="checkAll(this)">全选<br><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
</div>
</body>
</html>

时间: 2024-08-02 10:11:28

jquery实现checkbox的全选的相关文章

【Jquery】checkbox的全选和全不选

刚学Jquery,在做checkbox的全选全不选时遇到了一个问题,使用attr()方法的话, 只能成功全选和取消全选一次,第二次就不行了,如下面 $("#chkAll").click(function(){ if(this.checked==true){ $("#tab input[type='checkbox']").attr("checked",true); }else{ $("#tab input[type='checkbox'

jquery 实现 checkbox的全选操作

<title>jQuery实现CheckBox全选.全不选</title> <script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $("#checkAll&qu

jQuery实现checkbox的全选和反选

1 $(function () { 2 3 if ($(".chk_all")) { 4 5 $(".chk_all").click(function () { 6 $("input[checkname='choice']").prop("checked", $(this).prop("checked")); 7 }); 8 } 9 }); 如何使用: 1 <table > 2 <tr&g

jquery中checkbox的全选与反选

<script type="text/javascript"> 'use strict'; $(function () {  $("#c1").click(function () {     $('input[type="checkbox"]').prop("checked", this.checked)  }); }); </script> <body> <div id="

jQuery实现checkbox(复选框)选中、全选反选代码

谁都知道 在html 如果一个复选框被选中 是 checked="checked". 但是我们如果用jquery alert($("#id").attr("checked")) 会提示您是true而不是checked 所以很多朋友判断  if($("#id").attr("checked")=="true") 这个是错误的,其实应该是 if($("#id").attr

在项目中学习.NET的JQuery CheckBox方法(全选、取消全选、其他)

一.在项目中遇到的CheckBox的全选和取消全选以及其他等解决方案如下: // 对全选和取消全选的事件 $("#CheckAll").click(function () {                var checkedOfAll = $(this).prop("checked");                if (checkedOfAll == true) {                    $("input[id*='check']

JQUERY的给Check全选功能

//给Checkbox提供全选功能 $("#checkall").click(function(){ if(this.checked){ $("input[name='checkname[]']").each(function(){ this.checked = true; }); }else{ $("input[name='checkname[]']").each(function(){ this.checked = false; }); }

html checkbox 实现全选/取消全选

html checkbox  实现全选/取消全选 <html> <body> <table border="1"> <tr> <th><input type="checkbox" onclick="swapCheck()" /></th> <th>Month</th> <th>Savings</th> </tr

JQuery操作TreeView的全选,反选

1 <asp:TreeView ID="tv" runat="server" ExpandDepth="2" ShowCheckBoxes="All" 2 ShowLines="True" ImageSet="Msdn" > 3 </asp:TreeView> JavaScript部分代码 1 $( 2 function () { 3 //顶级选择 4 $(&qu