<form>
  你爱好的运动是?
  <input type="checkbox"   />4
</form>

在第一个复选框中添加click()事件,

核心的jQuery代码如下:

<script type="text/javascript">
  $(document).ready(function(e) {
  $("#hxy").click(function(){
    if(this.checked){
        $("[name=hxy]").attr("checked",true);

      }else{

        $("[name=hxy]").attr("checked",false);

      }
    });
  });
</script>

这样就完成了一个最基本的全选/全不选的实例。

相关文章:

  • 2022-02-10
  • 2021-06-30
  • 2021-08-05
  • 2022-02-17
  • 2021-12-11
  • 2021-12-02
  • 2021-09-28
  • 2021-06-11
猜你喜欢
  • 2021-05-22
  • 2022-01-13
  • 2022-01-23
  • 2022-12-23
  • 2021-11-15
  • 2021-05-02
  • 2021-11-21
相关资源
相似解决方案