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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -