Created
May 21, 2015 07:12
-
-
Save emojiijome/7100d5eb0f01c41bda69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
//全不选 | |
$("#btnAllNotChk").click(function () { | |
$("#chk input:checkbox").removeAttr("checked"); | |
}); | |
//全选 | |
$("#btnAllChk").click(function () { | |
$("#chk input:checkbox").attr("checked", "checked"); | |
}); | |
//反选 | |
$("#btnInvert").click(function () { | |
//1.方法一实现反选 | |
$("#chk input:checkbox").each(function () { | |
this.checked = !this.checked; | |
}) | |
//2.方法二实现反选 | |
// $("#chk input:checkbox").each(function (){ | |
// if ($(this).attr("checked")) { | |
// $(this).attr("checked", false); | |
// } | |
// else { | |
// $(this).attr("checked", "checked"); | |
// } | |
// }) | |
//3.方法三实现反选 | |
// var $cks = $("#chk input:checkbox"); | |
// for (var i = 0; i < $cks.length; i++) { | |
// $cks.get(i).checked = !$cks.get(i).checked; | |
// } | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment