Javascript 创造;选择全部";按钮选择所有按钮
因此,我有一个包含多行的表。我试图用一个按钮选择每一行;另外,在表标题中,有一个全选按钮,它将选择所有行中的所有按钮。以下是html:Javascript 创造;选择全部";按钮选择所有按钮,javascript,jquery,angularjs,twitter-bootstrap,Javascript,Jquery,Angularjs,Twitter Bootstrap,因此,我有一个包含多行的表。我试图用一个按钮选择每一行;另外,在表标题中,有一个全选按钮,它将选择所有行中的所有按钮。以下是html: <table class="table" ng-controller="myController"> <thead> <tr class="info"> <th>Company Name</th> <th>Address</th>
<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>
公司名称
地址
{{company.name}
{{company.address}
如何使用jQuery创建函数来更改所有行的值?有什么想法吗?在“全选”复选框上设置一个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>
公司名称
地址
{{company.name}
{{company.address}
您使用的是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>
这里是角度代码
$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;
});
};
})) 对。按#全选按钮,将#选择一个按钮更改为aria pressed=“true”。使用angular,这是否存在于指令中?这些按钮的默认值为“false”。在
ng repeat
中设置一个scope
likearia pressed=“{company selected}”
$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;
});
};