Reputation: 1825
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();
})
Upvotes: 0
Views: 4689
Reputation: 4215
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>
Upvotes: 3