创建“;“全选”;按钮选择所有按钮
Creating "select all" button to select all buttons
所以,我有一个有多行的表。我试着用一个按钮来选择每一行;此外,在表格标题中,有一个全选按钮,它将选择所有行中的所有按钮。这是html:
<table class="table" ng-controller="myController">
<thead>
<tr class="info">
<th>Company Name</th>
<th>Address</th>
<th>
<input type="button" class="btn btn-default" id="select-all" data-toggle="button" value="Show All" aria-pressed="false">
</th>
</tr>
</thead>
<tbody ng-repeat="company in fieldData">
<tr>
<td>{{ company.name }}</td>
<td>{{ company.address }}</td>
<td style="text-align: center">
<input type="button" class="btn btn-default" id="select-one" data-toggle="button" value="Show" aria-pressed="false">
</td>
</tr>
</tbody>
</table>
如何使用jQuery创建一个函数来更改所有行的aria压缩值?有什么想法吗?
您使用的是Angular js吗。
我已经写了一个简单的代码,看看
<div>
<ul ng-controller="checkboxController">
<li>Check All
<input type="checkbox" ng-model="selectedAll" ng-click="checkAll()" />
</li>
<li ng-repeat="item in Items">
<label>{{item.Name}}
<input type="checkbox" ng-model="item.Selected" />
</label>
</li>
</ul>
angular.module("CheckAllModule", [])
.controller("checkboxController", function checkboxController($scope) {
此处为角度代码
$scope.Items = [{
Name: "Item one"
}, {
Name: "Item two"
}, {
Name: "Item three"
}];
$scope.checkAll = function () {
if ($scope.selectedAll) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.Items, function (item) {
item.Selected = $scope.selectedAll;
});
};
});
在"全选"复选框上设置一个ng模型,然后使用ng-checked
指令全选/取消全选。
<table class="table" ng-controller="myController">
<thead>
<tr class="info">
<th>Company Name</th>
<th>Address</th>
<th>
<input type="button" ng-model="selectAll" class="btn btn-default" id="select-all" data-toggle="button" value="Show All" aria-pressed="false">
</th>
</tr>
</thead>
<tbody ng-repeat="company in fieldData">
<tr>
<td>{{ company.name }}</td>
<td>{{ company.address }}</td>
<td style="text-align: center">
<input type="button" class="btn btn-default" id="select-one" data-toggle="button" value="Show" aria-pressed="false" ng-checked="selectAll">
</td>
</tr>
</tbody>
</table>
相关文章:
- 根据页面加载时的单选按钮选择显示某些字段
- 使用JavaScript或jQuery检查单选按钮选择是否与数组中的项目匹配
- Ng点击记住单选按钮选择
- Angular未更新单选按钮选择
- jQuery为按钮选择设置活动类
- 阅读JS中的单选按钮选择
- JQuery IE11 单选按钮选择器
- 确认单选按钮选择
- 贝宝表单问题的单选按钮选择
- 使用javascript在单选按钮选择上加载URL
- 创建“;“全选”;按钮选择所有按钮
- 如何更改用户选项更改时中的Onchange事件中Visual Composer上的按钮(选择选项)
- 显示基于多个单选按钮选择的图像
- 基于输入值的单选按钮选择
- 将域类id返回到由单选按钮选择的控制器
- Jquery:单击按钮选择下拉选项
- 无法更改单选按钮选择 - KnockoutJS
- 单选按钮选择列表框更改并将 NULL 值传递给每个列表框
- 用户在Javascript的帮助下,仅通过单选按钮选择一个付款方式(信用卡)
- 基于多个单选按钮选择显示或隐藏元素