jquery select all checkboxes

前端 未结 19 2746
情书的邮戳
情书的邮戳 2020-12-13 12:36

I have a series of checkboxes that are loaded 100 at a time via ajax.

I need this jquery to allow me to have a button when pushed check all on screen. If more are lo

19条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 13:15

    So "checked" is a crappy attribute; in many browsers it doesn't work as expected :-( Try doing:

    $('#friendslist').find(':checkbox')
        .attr('checked', this.checked)
        .attr('defaultChecked', this.checked);
    

    I know setting "defaultChecked" doesn't make any sense, but try it and see if it helps.

提交回复
热议问题