jquery - Check all checkbox does not work -
in jsfiddle
code:
<script type="text/javascript"> function checkall() { var checked = $("#checkall").is(':checked'); $(".check_row").attr("checked", checked); } </script> <div> <input type="checkbox" id="checkall" onclick="checkall()" />check <br /> <input type="checkbox" class="check_row" />one <br /> <input type="checkbox" class="check_row" />two <br /> <input type="checkbox" class="check_row" />three <br /> <input type="checkbox" class="check_row" />four <br /> <input type="checkbox" class="check_row" />five <br /> <input type="checkbox" class="check_row" />six <br /> </div>
"check all" checkbox works first time. can me find out wrong happening?
change
$(".check_row").attr("checked", checked);
to
$(".check_row").prop("checked", checked);
see fiddle
Comments
Post a Comment