js实现全选功能

HTML
名称 账号 行业 区域
1 2 3 武汉
------------------------------------------------------------------------------------------------ CSS .aui-check { width: 20px; height: 20px; position: relative; margin: 8px 10px; background: url(../img/check.png) no-repeat center; display: table; float: left; -webkit-appearance: none; transition: background-color ease 0.1s; text-align: center; } .aui-check:checked { background: url(../img/checked.png) no-repeat center; } ------------------------------------------------------------------------------------------------ JS $('#checkall').on('click', function() { $("input[name='sub']").prop("checked", this.checked); }) $("input[name='sub']").on('click', function() { var $subs = $("input[name='sub']"); $(".checkall").prop("checked", $subs.length == $subs.filter(":checked").length ? true : false); })

你可能感兴趣的:(js实现全选功能)