要求:在输入框中输入值以后,按回车键触发某一事件的执行
html:
<input id="input" name="input" ng-model="querykdUser.page.pageSize" ng-keyup="myKeyup($event)" class="form-control" style="width:60px;">
js:
$scope.myKeyup = function(e){
//IE 编码包含在window.event.keyCode中,Firefox或Safari 包含在event.which中
var keycode = window.event?e.keyCode:e.which;
if(keycode==13){
$scope.showkdUsers();
}
};
回车键:13
左箭头键:37
右箭头键:39
本文介绍如何使用AngularJS在用户于输入框中按下回车键(键码13)时触发特定函数。通过监听键盘事件,实现对输入操作的响应。
5074

被折叠的 条评论
为什么被折叠?



