1
入力時にオートフォーカスが表示されません。 オートフォーカスのプロパティは、Chromeで断続的に機能します。 IE11で...うーん、それを追加しようとしません。elemが表示されているときにオートフォーカスが動作しないok
jQueryでオートフォーカスを適用する前に、DOM上にinput要素の存在を検証する必要がありますか?
HTML5
<input type="text" class="form-control" autofocus placeholder="Filter">
JS
function iboxHistorySearch() {
var header = $('.client-history .ibox-title_replace'),
searchbar = $('.client-history .client-history-searchbar'),
closeBtn = $('.client-history .btn-dismiss');
header.on('click', function (e) {
e.preventDefault();
if (searchbar.hasClass('hidden')) {
searchbar.removeClass('hidden')find('form-control:first').focus();
$(this).addClass('hidden');
}
});
closeBtn.on('click', function (e) {
e.preventDefault();
if (header.hasClass('hidden')) {
header.removeClass('hidden');
searchbar.addClass('hidden');
}
});
}
iboxHistorySearch();
UPDATE(未編集)質問から
searchbar.removeClass('hidden')find('form-control:first').focus();
を確認してください。https://jsfiddle.net/br3t/xbg5fyac/正しい例ですか?私のためにうまくいく。 – br3t
厳密にどの要素に集中しようとしていますか? '.client-history-searchbar'は 'input'のようには聞こえず、divのように聞こえます。 'searchbar.removeClass( 'hidden')を意味しましたか?find( 'form-control:first')。focus()'? –
@ br3t htmlレイアウト –