skip to Main Content

ISSUE : Auto focus is not applying to my pop up form of bootstrap 2.1

I am using twitter bootstrap 2.1 trying to autofocus on first input element when click and a pop up is show.

I need guidance to resolve this issue. I have try with JavaScript focus function and also try with html autofocus property but it is not applying.

Bootstrap modal show event

I tried this stack overflow question but it require to update my bootstrap to 3.0 but it is not possible for me to update as it require huge time.

I want similar autofocus with bootstrap 2.1 please guide me towards this.

Thanks in advance



  1. Chosen as BEST ANSWER

    its general solutions for all used modal no need to write method for individual modal you can try this

    $('.modal').on('shown', function () {
            var first_elemt = $('.modal').filter(':visible:first').find('input[type=text]').attr('id');

  2. I solve this…

    Bootstarp model have “shown” event. It fires after model open. Just put your code for focus first element of form on the event function. Like below

    $('your-model-id').on('shown', function () {
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top