jQuery---prop方法和表格全选案例

时间:2023-03-09 02:55:36
jQuery---prop方法和表格全选案例

prop方法和表格全选案例

jQuery---prop方法和表格全选案例

对于布尔类型的属性,不用attr方法,应该用prop方法 prop用法跟attr方法一样

  <input type="button" value="选中">
<input type="button" value="不选中">
<input type="checkbox" id="ck">
<script src="jquery-1.12.4.js"></script>
<script>
//对于布尔类型的属性,不用attr方法,应该用prop方法 prop用法跟attr方法一样。
$(function () {
$("input").eq(0).click(function () {
$("#ck").prop("checked", true);
}); $("input").eq(1).click(function () {
$("#ck").prop("checked", false);
});
});
</script>

jQuery---prop方法和表格全选案例