1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Set focus on bootstrap modal element

Discussion in 'Web Design & Development' started by JiminSA, May 8, 2015.

Thread Status:
Not open for further replies.
  1. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    3,387
    First Name:
    Jim
    Trying to set focus on the first input element on a bootstrap modal form, using javascript, is proving difficult.:(
    Astonishingly, the javascript below causes the cursor to blink once as the modal is rendered and then disappear!:confused:
    Code:
    <script>
    $(document).ready(function() {
        $(".modal").on('shown.bs.modal', function() {
            $(this).find("[autofocus]:first").focus();
        });
    });
    </script>
    Any ideas?;) (You know I'm hopeless with javascript)
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - focus bootstrap modal
  1. howard.a.s
    Replies:
    12
    Views:
    420
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1147916

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice