码迷,mamicode.com
首页 > 其他好文 > 详细

实现checkbox全选和全不选的功能

时间:2014-07-26 03:37:47      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:io   re   c   cti   html   代码   ar   htm   

html代码
<table id="table">
			<thead>
				<tr>
					<td><input type="checkbox" id="thtd" name="thtd"/></td>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td><input type="checkbox" id="tbtd" name="tbtd"/></td>
				</tr>
				<tr>
					<td><input type="checkbox" id="tbtd" name="tbtd"/></td>
				</tr>
				<tr>
					<td><input type="checkbox" id="tbtd" name="tbtd"/></td>
				</tr>
			</tbody>
		</table>

js代码

$(document).ready(function(){
		$("#thtd").bind("click",function(){
			alert($(this).prop("checked"));
			var flag = $(this).prop("checked");
			if(flag){
				$("#table #tbtd").prop("checked",true);
			}else{
				$("#table #tbtd").prop("checked",false);
			}
		})
	});





实现checkbox全选和全不选的功能,布布扣,bubuko.com

实现checkbox全选和全不选的功能

标签:io   re   c   cti   html   代码   ar   htm   

原文地址:http://my.oschina.net/u/1026723/blog/294860

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!