jQuery实现全选取消反选
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>jQuery实现全选取消反选</title> <script type="text/javascript" src="jquery-1.10.2.js"></script> <script type="text/javascript"> $(function() { //全选 $(".checkAll").on("click", function() { var checked = $(this).prop("checked"); $(".checkChild").each(function(i) { if ($(this).attr("disabled") != "disabled") { $(this).prop("checked", checked); } }); }); //反选 $(".reverseCheck").on("click", function() { $(".checkChild").each(function(i) { if ($(this).prop("checked")) { $(this).prop("checked", false); } else { $(this).prop("checked", true); } }); }); //取消 $(".checkChild").click(function() { var flag = true; $(".checkChild").each(function(i) { if (!$(this).prop("checked")) { flag = false; } }); if (flag) { $(".checkAll").prop("checked", true); } else { $(".checkAll").prop("checked", false); } }); }); </script> </head> <body> <h5>js实现全选取消</h5> <input type="checkbox" name="checkAll" class="checkAll" />全选 <input type="checkbox" name="reverseCheck" class="reverseCheck" />反选 <input type="checkbox" name="checkChild" class="checkChild" />语文 <input type="checkbox" name="checkChild" class="checkChild" />数学 <input type="checkbox" name="checkChild" class="checkChild" />英语 <input type="checkbox" name="checkChild" class="checkChild" />地理 </body> </body> </html>
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17