你的位置:首页 > 软件开发 > Java > jQuery中的checkbox问题

jQuery中的checkbox问题

发布时间:2016-08-09 18:00:18
一开始的代码:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>复选框</title ...

一开始的代码:

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>复选框</title>  <script src='/images/loading.gif' data-original="https://cdn.bootcss.com/jquery/3.1.0/jquery.min.js"></script>  <script type="text/javascript">  $(function() {    $("#all").click(function () {      if (this.checked) {        $("#list :checkbox").each(function () {          $(this).attr("checked", true);  //选择器要有空格隔开        })      } else {        $("#list :checkbox").each(function () {          $(this).attr("checked", false);        })      }    });  })</script></head><body><ul id="list">  <li><label><input type="checkbox" value="1">广东省 </label></li>  <li><label><input type="checkbox" value="2">广西省 </label></li>  <li><label><input type="checkbox" value="3">河南省 </label></li>  <li><label><input type="checkbox" value="4">福建省 </label></li>  <li><label><input type="checkbox" value="5">湖南省 </label></li>  <li><label><input type="checkbox" value="6">江西省 </label></li></ul><input type="checkbox" id="all"><input type="button" value="全选" class="btn" id="selectAll"><input type="button" value="全不选" class="btn" id="unSelect"><input type="button" value="反选" class="btn" id="reverse"><input type="button" value="获得选中的所有值" class="btn" id="getValue"></body></html>

原标题:jQuery中的checkbox问题

关键词:jquery

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录