最精简的js代码,实现checkbox,全选、反选、过滤disabled

来源:互联网 发布:合肥行知 编辑:程序博客网 时间:2024/06/14 20:00
很多人都知道全选反选一句话:
$('input[type=checkbox]').prop('checked', $(this).prop('checked'));
要过滤disable可以这么写:
$('input[type=checkbox]').prop('checked', function(i, val){<span style="white-space:pre"></span>if(!$(this).prop('disabled') && i > 0){<span style="white-space:pre"></span>return !val;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>});


0 0
原创粉丝点击