jquery全选功能

  1. <input type="checkbox" id="c" name="c" title="全选/全不选" onclick="selectAll(this.checked,'list')" />
  2. <input type="checkbox" name="list" />
  3. <input type="checkbox" name="list" />
  4. <input type="checkbox" name="list" />
  5. <input type="checkbox" name="list" />
  6. <input type="checkbox" name="list" />
  7. <input type="checkbox" name="list" />
  8. <a href="javascript:void(0)" onclick="selectAll(true,'list')">全选</a> - <a href="javascript:void(0)" onclick="selectAll(false,'list')">全不选</a>

 

 

  1. function selectAll(flag, checkBoxName) {
  2. $("input:checkbox[name='" + checkBoxName + "']").each(function () {
  3. $(this).attr("checked", flag);
  4. });
  5. }

你可能感兴趣的:(jquery)