while making a web I didn\'t get focus in a \"input\" into Bootstrap Modal, I tried everything and didn\'t work, modal appears but input doesn\'t get focus. I have make a \"test
Try this:
$('#modal_id').modal('show').on('shown.bs.modal', function() {
$('input_element_id').focus();
});
Or Try This:
$('#modal_id').on('shown.bs.modal', function() {
$('input_element_id').focus();
});
$('#modal_id').modal('show');
Try this (autofocus added to your link):
<input name="referencia" id="referencia" type="text" class="form-control text-uppercase" placeholder="Descripción" autofocus>
or try this:
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus();
})
or this:
// Every time a modal is shown, if it has an autofocus element, focus on it.
$('.modal').on('shown.bs.modal', function() {
$(this).find('[autofocus]').focus();
});