Jquery $.focus() Not Working With Id And With Input Type
I have a little problem: I have a modal that opens after some result search with ajax: it opens and show all requested results correctly. On close, I need to empty another div with
Solution 1:
Problems with trying to use .focus()
in an event handler usually stem from the event being handled also having an affect on focus. To get around that, I usually just wrap the .focus()
call in a timeout:
$(".modal").on('hidden.bs.modal', function () {
$("#results").empty();
$("#searc").val('');
setTimeout(function() {
$("#searc").focus();
}, 10);
});
The timeout handler will run basically immediately after whatever triggered the event handler is all finished.
Post a Comment for "Jquery $.focus() Not Working With Id And With Input Type"