我已应用此方法,效果很好。
<input type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
</input>
当用户尝试其他输入而不是数字时,它是否有可能发出警告信息。非常感谢帮助或建议。谢谢
答案 0 :(得分:0)
检查this代码:
//HTML
<div ng-app>
<div class=" header-row">
<div class="col">Name</div>
<div class="col">Sports</div>
<div class="col">Score</div>
</div>
<div ng-controller="TodoCtrl">
<div class="row" ng-repeat="rows in chunkedData">
<div class="span4" ng-repeat="item in rows">
<span class="col">{{item.name}}</span>
<span class="col">{{item.sport}}</span>
<span class="col">{{item.score}}</span>
</div>
</div>
</div>
</div>
//Script
function TodoCtrl($scope) {
$scope.data = [
{
name : '0',
sport: 'Cricket',
score: 89
},
{
name : '1',
sport: 'Cricket',
score: 89
},
{
name : '2',
sport: 'Cricket',
score: 89
},
{
name : '3',
sport: 'Cricket',
score: 89
},
{
name : '4',
sport: 'Cricket',
score: 89
},
{
name : '5',
sport: 'Cricket',
score: 89
},
{
name : '6',
sport: 'Cricket',
score: 89
}
];
$scope.chunkedData = chunk($scope.data, 3);
function chunk(arr, size) {
var newArr = [];
for (var i=0; i<arr.length; i+=size) {
newArr.push(arr.slice(i, i+size));
}
return newArr;
}
}
//CSS
.col{
display: inline-block;
width:70px;
float: left;
padding: 3px;
}
.header-row{
width: 100%;
background-color: #000;
color: #fff;
overflow: hidden;
padding: 3px;
}
.row{
overflow: hidden;
display: inline-block;
float: left;
border: 1px solid grey;
}
fadeOut()示例; Check