利用jquery實(shí)現(xiàn)的全選,或者有些人認(rèn)為用js更容易些,這就是個(gè)人對(duì)知識(shí)的掌握了。
最近看到很多人在問(wèn)如何實(shí)現(xiàn)全選 不選 反選這些功能
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#setall").click(function () {
$("#inputlist :input[name=check]").attr("checked", true);
});
$("#setNotall").click(function () {
$("#inputlist :input[name=check]").attr("checked", false);
});
$("#setallC").click(function () {
$("#inputlist :input[name=check]").each(function () {
$(this).attr("checked", !$(this).attr("checked"));
});
});
});
</script>
這里就是全部jquery代碼了
JQuery實(shí)現(xiàn)全選與取消更加簡(jiǎn)單的一種:
[java] view plaincopyprint?
01.$("#checkall").click(
02. function(){
03. if(this.checked){
04. $("input[name='checkname']").attr('checked', true)
05. }else{
06. $("input[name='checkname']").attr('checked', false)
07. }
08. }
09.);