i using bootstrap 3 tabs. directly jump specific tab, use following code:
function tabnavigation() { if (location.hash.indexof("#tab_") == 0 && $('a[href="' + location.hash + '"]').length) { var $d = $('a[href="' + location.hash + '"]'); } else { $d = $(".tabnavigation a:first"); } $d.tab('show'); $(location.hash + " [autofocus]").first().focus(); } window.addeventlistener("hashchange", tabnavigation, false); tabnavigation(); $("body").on("click", ".tabnavigation a", function () { window.location.hash = $(this).attr("href").substr(1); }); });
this works expected. problem is, if there autofocus attribute on 1 of tabs, doesn't work in firefox (but works in chrome).
<input class="form-control" autofocus id="input2" required="required" name="input2" type="text">
i have tried js:
$("[autofocus]").first().focus();
have @ bootplay (works in chrome, not in firefox):
http://www.bootply.com/in1e0qtvif
but works neither. ideas?
only 1 form element in document can have
autofocus
attribute
you have multiple <input>
s autofocus
attribute, document isn't valid html.
Comments
Post a Comment