select all checkboxes command jquery, javascript

前端 未结 3 839
小蘑菇
小蘑菇 2021-01-24 08:02

I\'m trying to get all of my checkboxes to be checked when clicking a link

looks like this: sele

相关标签:
3条回答
  • 2021-01-24 08:13

    You're going to want to use the [name^=delete] selector ("starts with"), since your checkboxes names aren't exactly "delete", they're "delete[X]' for some number X.

    0 讨论(0)
  • 2021-01-24 08:21

    Try the following.

    Updated. The handler is tied to an anchor therefore there will be no this.checked attribute available.

    $("#select_all").click(function(){
        $("input[name^=delete]").attr('checked',  'checked');  
    });
    
    0 讨论(0)
  • 2021-01-24 08:24

    jQuery Tutorial: Select All Checkbox

    0 讨论(0)
提交回复
热议问题