Jquery “select all” checkbox

后端 未结 11 611
执念已碎
执念已碎 2020-12-06 05:45

I am trying to select all checkboxes on a page once the \'select all\' checkbox is clicked and i am using jquery for this as you can see at the below link:

http://js

11条回答
  •  有刺的猬
    2020-12-06 06:18

    You can simply add the handle function to the click event on the select all checkbox:

    $('#chk-all-items').click(selectAll);
    

    And then this function should be enough to select all or unselect all.

    selectAll = function (event) {
            var self = this;
            $('.template-item-select').each(function () {
                this.checked = self.checked;
            });
        }
    

提交回复
热议问题