有时点击按钮 只是把文本框显示 但是并没有获得焦点,也就是没弹出键盘。有时又可以正常弹出键盘 。。很奇怪。查不出原因。。我测的是iphone5。。代码很简单。。反正我想要的效果是 点击按钮自动弹出键盘。<div ng-controller="myctrl">
<button id="btn" ng-click="aClick()">点击</button>
<input type="text" id="myinput" ng-show="isShow">
</div>
<script type="text/javascript">
var app = angular.module("app",[]);
app.controller("myctrl",function($scope,$timeout){
$scope.aClick = function(){
$timeout(function(){ document.getElementById("myinput").focus();
})
$scope.isShow = true;
}
}) </script>
1 回答

ABOUTYOU
TA贡献1812条经验 获得超5个赞
document.getElementById("myinput").focus();
改成
angular.element('#myinput').focus();
试试
还有,要把jquery的类库加进去
添加回答
举报
0/150
提交
取消