html:
  <input  type="checkbox" id="checkbox1" value="1" onclick="check1()"/>
  <input type="checkbox" name="checkbox1" value="${article.id}"/>
  <input type="checkbox" name="checkbox1" value="${article.id}"/> js:
function check1(){
var store1=document.getElementById('checkbox1');
store1.value==1?store1.value=2:store1.value=1;
var store1_checkbox=document.getElementsByName('checkbox1');
for(var i=0;i<store1_checkbox.length;i++){
if(store1.value==1){
store1_checkbox[i].checked=true;
}
else{
store1_checkbox[i].checked=false;
}
}
}
第二种方法

/*全选反选*/

<div class="nav nav-tabs " id="left_nav">
  <h1><input type="checkbox" name="carchecked" id="carchecked" />车辆缴费</h1>
  <ul>
    <li><input type="checkbox" name="carchecked"/>grw</li>
    <li><input type="checkbox" name="carchecked"/>few </li>
    <li><input type="checkbox" name="carchecked"/>greg</li>
    <li><input type="checkbox" name="carchecked"/>fgwe</li>
  </ul>  
  <h1><input type="checkbox" name="reportchecked" id="reportchecked" />报表查询</h1>
  <ul>
    <li><input type="checkbox" name="reportchecked" />grw</li>
    <li><input type="checkbox" name="reportchecked" />few </li>
    <li><input type="checkbox" name="reportchecked" />greg</li>
    <li><input type="checkbox" name="reportchecked" />fgwe</li>
  </ul>

</div>

$("#carchecked").change(function() {
$('input[name="carchecked"]').prop("checked",this.checked);
});
$("#reportchecked").change(function() {
$('input[name="reportchecked"]').prop("checked",this.checked);
});


js全选checkbox框的更多相关文章

  1. JS全选checkbox

    <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/ ...

  2. JS全选功能代码优化

    原文:JS全选功能代码优化 JS全选功能代码优化 最近在看javascript MVC那本书,也感觉到自己写的代码也并不优雅,所以一直在想 用另一种模式来编写JS代码,所以针对之前的简单的JS全选功能 ...

  3. 简单JS全选、反选代码

    1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org ...

  4. 当鼠标点击input框时,想让全选input框的所有内容只需要加“onfocus="this.select();”就可以了

    当鼠标点击input框时,想让全选input框的所有内容只需要加“onfocus="this.select();”就可以了

  5. js——全选框 checkbox

    一直会碰见input 全选框的问题,先整理一种情况: 1. <input id="selectAll" type="checkbox" />全选 2 ...

  6. 关于如何用js完成全选反选框等内容

    在学习js过程中按照视频写了这个页面 可以在点上面全选/全不选时全部选中或者取消 在单击下面的单选框时上面的全选会根据下面的单选框进行相应的调整 功能比较完善 以下是代码 <!DOCTYPE h ...

  7. js实现全选checkbox

    js代码 function selectAllCheckBox(parentid) { var PID = document.getElementById(parentid); var cb = PI ...

  8. jquery、js全选反选checkbox

    操作checkbox,全选反选 //全选 function checkAll() { $('input[name="TheID"]').attr("checked&quo ...

  9. js 全选选框与取消全选代码

    设置一个全选选框和四个子选框,要实现点击全选后四个子选框选中,取消全选后四个子选框也取消.全选后点击某个子选框,全选也能取消.当四个子选框都选中时,全选框也被选择. 实现代码: <script& ...

随机推荐

  1. ci公共模型类

    我们都知道,操作数据库的方法都写在模型中.但是一般情况下,一张表往往至少对应4个操作,也就是所谓crud.那么如果20张表,所对应的模型方法,就达到了80个,重复的操作显然这已经是一个体力活儿. 那么 ...

  2. Yii 2.0 ActiveForm生成表单 ,控制表单label和filed样式,filed一旦报错,前面lable颜色跟着变,看图,帮你解决

    需要生成如下图的表单样式,图一:

  3. http-server 命令行

    安装 (全局安装加 -g) : npm install http-server (npm install --global http-server) 在站点目录下开启命令行输入 http server ...

  4. UI状态控制

    if(BillBaseStatusEnum.ADD==this.editData.getBaseStatus()){ this.btnSave.setEnabled(true); this.btnSu ...

  5. 通过 Composer Github Packagist制作发布共享PHP包

    参考来源: https://laravel-china.org/topics/1002 https://rivsen.github.io/post/how-to-publish-package-to- ...

  6. ubuntu中文输入问题

    因为硬盘版的一些缺陷,我狠心的把windows8覆盖为ubuntu 13.10,用u盘安装,除了分区稀里糊涂的还不知到怎么分,其他问题就是汉字的输入问题了,因为之前选了english-US 后来就没有 ...

  7. 本地存储和cookies之间的区别

  8. [译]Selenium Python文档:二、初步开始

    2.1.简单使用 如果已经安装好了Selenium Python,你就可以像下面这样编写Python代码来使用它了: from selenium import webdriver from selen ...

  9. SqlCommandBuilder类是如何构建T-Sql语句

    本篇博客默认你看了[DataTable中AcceptChanges()方法的DataRowRowState属性]这篇博客. 在使用SqlCommandBuilder很简单,就是创建一个SqlComma ...

  10. linux shell 找端口号及对应的进程

    #!/bin/bash#author:zhongyulin#crteate-time:2016-10-20 netstat -lnpt|grep -v grep>/tmp/script/nets ...