<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
<style>#testDiv{height:30px;width: 200px;border: 1px solid blue}</style>
<script>
$(function(){
$("#testDiv").click(function(){
$(this).find(":checkbox")[0].checked=!$(this).find(":checkbox")[0].checked;
}) })
</script>
<div id="testDiv">
<input type="checkbox" />
</div>
用原生是因为jquery不同版本库对checked属性支持有一点不同
<input type="checkbox" />
</div>这个要重复生成的。。
<input type="checkbox" />
</div>
<script>
$(function(){
$(".checkable").click(function(){
$(this).find(":checkbox")[0].checked=!$(this).find(":checkbox")[0].checked;
})
})
</script>
/*table tr 点击选中复选框*/
$(".content_list tr").slice(1).each(function(){
var p = this;
$(this).children().slice(1).click(function(){
$($(p).children()[0]).children().each(function(){
if(this.type=="checkbox"){
if(!this.checked){
this.checked = true;
}else{
this.checked = false;
}
}
});
});
});
html
[code=html]
<table border="0" cellpadding="0" cellspacing="0" class="content_list">
<tr class="tb_header">
<th width="2%"></th>
<th width="5%">编号</th>
<th width="">文章名称</th>
<th>分类</th>
<th width="8%">作者</th>
<th>内容</th>
</tr>
<tr class="tb_list">
<td><input type="checkbox" name="id[]" value="118"></td>
<td>118</td>
<td>mysql mysqladmin: command not fo </td>
<td>mysql</td>
<td>bloack boy</td>
<td>有时候安装好</td>
<td>23</td>
</tr>
</table>[/code]
<div style='background:#ddd'>
<input id='ck' type="checkbox" />
</div>
</label>