如何角指令適用這個jQuery如何啓用第一輸入焦點在角JS指令
jQuery的
$(":input:not(input[type=button],input[type=submit],button):enabled:visible:first").focus();
我曾嘗試以下,但沒有運氣
角指令鏈接
.directive('autoFocus', ['$timeout', function ($timeout) {
return {
scope: {
autoFocusInitial: "="
},
link: function (scope, element, attrs) {
if (scope.autoFocusInitial == true) {
$timeout(function() {
element[0].querySelector("input:not(.ng-hide)").filter(":enabled:visible:first").focus();
});
}
}
};
}
將方便看到你的HTML –
不能使用自動對焦屬性呢? – GillesC
@GillesC我具有基於條件的條件輸入元件,第一元件將被啓用。最後,無論哪個輸入都應該被關注。 – klmuralimohan