当一个页面出现多个checkbox全选时的处理

HTML:

<input type="checkbox" onclick="boxOnclick(this,'some1')">全选一

<input type="checkbox" onclick="boxOnclick(this,'some2')">全选二

<input type="checkbox" onclick="boxOnclick(this,'some3')">全选三

<input type="checkbox" class="some1">全选一的子集

<input type="checkbox" class="some2">全选二的子集

<input type="checkbox" class="some3">全选三的子集

JS:

function boxOnclick(obj, someNum) {

  if (obj.checked) {

    $("." + someNum).each(function () {

      this.checked = true;

    });

  } else {

    $("." + someNum).each(function () {

      this.checked = false;

    });

  }

}

原文地址:https://www.cnblogs.com/Man-Dream-Necessary/p/5482817.html