當我在桌面或Android設備上運行應用程序時,輸入焦點工作正常。但它不適用於ios 10 Safari。我正在使用angularjs。ios 10自動對焦不對焦輸入
$timeout(function() {
var input = $element.find('.my-input-box')[0];
input.focus();
}, 500);
當我在桌面或Android設備上運行應用程序時,輸入焦點工作正常。但它不適用於ios 10 Safari。我正在使用angularjs。ios 10自動對焦不對焦輸入
$timeout(function() {
var input = $element.find('.my-input-box')[0];
input.focus();
}, 500);
由於您使用的是angularjs,因此您應該嘗試在角度上查找您的解決方案。
您是否嘗試過使用ngFocus。
我猜它可能是這樣的:
HTML:
<input ng-focus="YourVariable">
並設置YourVariable爲True。
或者您可以嘗試: - http://stackoverflow.com/questions/14859266/input-autofocus-attribute?rq=1 –
無需查找元素。您可以添加指令。
yourApp.directive('autofocus', ['$timeout', function($timeout) {
return {
restrict: 'A',
link : function($scope, $element) {
$timeout(function() {
$element[0].focus();
});
}
}
}]);
和使用,如: -
<input autofocus type="text"/>
$超時(函數(){。 $( '#someID')聚焦();} ,500);試試這個 –
檢查你的輸入元素是在DOM還是NOT? –
它在DOM中,這就是爲什麼在桌面和Android上工作 – Rohit