$(function(){
自动执行代码块!
自动执行代码块!
})
id选择器:append()方法是向包含内容的末尾追加内容,而通过prepend()向包含内容开头插入内容
JQuery中的点击事件:
<head>
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
</head>
<body>
总控制选框:<input type="checkbox" id="zxk" />
<table border="1" cellspacing="0">
<tr>
<td>
<input type="checkbox" class="singleChe">
</td>
<td>
1
</td>
</tr>
<tr>
<td>
<input type="checkbox" class="singleChe">
</td>
<td>
2
</td>
</tr>
</tr>
</table>
</body>
<script type="text/javascript">
$("#zxk").click(function(){
if($(this).prop("checked") == true){
$(".singleChe").prop("checked",true);
} else {
$(".singleChe").prop("checked",false);
}
})
</script>
</html>
$(“#id值”).click(function(){
点击时要处理的逻辑代码
});
$(“.singleChe:checked”);通过这个方法就可以选中class值是singleChe且被选中的元素。
<html>
<head>
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
</head>
<body>
总控制选框:<input type="checkbox" id="zxk" />
<table border="1" cellspacing="0">
<tr>
<td>
<input type="checkbox" class="singleChe">
</td>
<td>
1
</td>
</tr>
<tr>
<td>
<input type="checkbox" class="singleChe">
</td>
<td>
2
</td>
</tr>
</tr>
</table>
</body>
<script type="text/javascript">
$("#zxk").click(function(){
if($(this).prop("checked") == true){
$(".singleChe").prop("checked",true);
} else {
$(".singleChe").prop("checked",false);
}
})
</script>
</html>