最近有时间,就整理整理自己做过的项目~这是某学院的档案系统项目。
话不多说,进入正题
<div style="margin-left: 20px;display : inline">
<a class="btn btn-mini btn-info" th:value="${entity['card'].cardName}"
onclick="directElection(this)">全选</a>
<a class="btn btn-mini btn-warning" th:value="${entity['card'].cardName}"
onclick="reverseElection(this)">反选</a
</div>
//全选
function directElection(object) {
let value = $(object).attr('value');
$('input[name="' + value + '"]').each(function () {
// $(this).attr('checked', true);基于bootstrap的web模板里面的复选框会出现这样的漏洞:已经添加上cheched属性了,但是没有出现“√”,
// 在这种情况下,会发现点击复选框没反应,再点击一次才出现勾选,说明prop函数已经加上选中属性了,但是模板bug,没有出现勾选图案。
this.checked = true;
});
};
//反选
function reverseElection(object) {
let value = $(object).attr('value');
$('input[name="' + value + '"]').each(function () {
this.checked = !this.checked;
});
};