[英]Focus on the next element
我的js中有這行:
$('input')[$('input').index(this)+9].focus();
我想關注下一個元素,但是當執行此行時,我關注了下一個元素,但是我遇到了這個錯誤:
錯誤:[$ rootScope:inprog] $ apply已在進行中http://errors.angularjs.org/1.3.6/ $ rootScope / inprog?p0 =%24在beginPhase(角度為REGEX_STRING_REGEXP(angular.js:63)處應用)。 js:14706),位於HTMLInputElement的link.initTemplate(mtxCalendar.js:28)的link.setTemplate(mtxCalendar.js:23)的Scope。$ get.Scope。$ apply(angular.js:14450)。 (mtxCalendar.js:62)在HTMLInputElement.jQuery.event.dispatch(jquery.js:4409)在HTMLInputElement.jQuery.event.add.elemData.handle(jquery.js:4095)在Object.jQuery.event.trigger( jquery.js:4324)。 (的jquery.js:4875)
scope.pressButton = function (val) {
if (val === 'cross') {
$('#ui-datepicker-div').hide();
} else {
if($.datepicker._lastInput.className.split(' ')[0] === 'champs_returnDate') {
$('#ui-datepicker-div').hide();
} else{
if(!scope.$$phase) {
$('input')[$('input').index(this)+9].focus();
}
}
}
};
您需要通過執行$ timeout()來延遲執行
$timeout(function(){
$('input')[$('input').index(this)+9].focus();
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.