How to set focus on input field or textarea inside a Bootstrap modal on activation
belongs to collection: BOOTSTRAP / SASS Frequently Asked Questions
All Answers
total answers (1)
belongs to collection: BOOTSTRAP / SASS Frequently Asked Questions
total answers (1)
Use the jQuery
.focus()
methodYou can simply use the jQuery
.focus()
method to set the focus on the first input box or textarea inside the Bootstrap modal when it is loaded upon activation.Let's try out the following example to understand how it basically works:
The jQuery code in the above example simply finds the <input> element and set focus on it when modal is visible to the user using the modal's shown.bs.modal event.
need an explanation for this answer? contact us directly to get an explanation for this answer