I can set focus on first input, that works in all browsers(except IE):
$('#login').on('shown', function () {
$(login).find('input:visible:first').focus();
})
I need to call it after Bootstrap modal showing will be finished, so I'm calling it in shown function.
Also tried this code(not working):
$('#sign_up').on('shown', function () {
setTimeout(function () {
$(sign_up).find('input:visible:first').focus();
}, 100);
///working everywhere except explorer
$('#login').on('shown', function () {
$('#user_email').focus();
})
javascript
<script type="text/javascript">
function formfocus() {
document.getElementById('element').focus();
}
window.onload = formfocus;
</script>
jquery
$(document).ready(function(){
$('#element').focus();
});
JQUERY FOR IE 8
$(document).ready(function(){
setTimeout(function() {
$('#element').focus();
}, 10);
});
HTML
<form>
<input id="element" />
<input />
<input />
</form>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.