How to clear all checkbox When checkbox id=“checkAll” are checked?

后端 未结 4 1975
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 23:04

How to clear all checkbox When checkbox id=\"checkAll\" are checked ?

in my demo , when user checked checkbox id=\"checkAll\" all checkbox are

4条回答
  •  半阙折子戏
    2021-01-25 23:27

    If I'm understanding you correctly, you want to clear all the items when they click "Check All" - you might want to change the name to "Clear All" for clarity.

    If so, just add a simple ! in front of this.checked

    $('#checkAll').click(function () {
    $('input:checkbox').prop('checked', !this.checked); });

提交回复
热议问题