Phenomenon: When running for the first time, click select all the checkbox, you can select all, click again, you can cancel all. However, no matter how I clicked after that, it didn't work...
- <input type="checkbox" id="selectAll_top" />select all<br />
- <input type="checkbox" name="sel" class="combinedPay" />1<br />
- <input type="checkbox" name="sel" class="combinedPay" />2<br />
- <input type="checkbox" name="sel" class="combinedPay" />3<br />
- <script type="text/javascript">
- $("#selectAll_top").click(function(){
- if($("#selectAll_top").prop('checked')){
- $("#selectAll_end").attr("checked",true);
- $(".combinedPay").attr("checked",true);
- }else{
- $("#selectAll_end").attr("checked",false);
- $(".combinedPay").attr("checked",false);
- }
- });
- </script>
Solution:
Try changing attr to prop.
Some versions of jquery have this problem,
mainly the problem of attribute values and state values.