Tabulation, changing focus and waiting

Viewed 9

Suppose the following (very simplified) code.

<html>
    <head>
        <script
              src="https://code.jquery.com/jquery-3.6.1.min.js"
              integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ="
              crossorigin="anonymous"></script>
    </head>

    <body>
    <script>
        jQuery('document').ready(function() {
            $('#b').hide();
            $('#a').change(function() {
                if ($(this).val() === 'b') {
                    $('#b').show();
                }
            });
        });
    </script>
        <form>
            <input name="a" id="a" value="a" />
            <input name="b" id="b" value="b" />
            <input name="c" id="c" value="c" />
    </body>
</html>

The user writes "b" in the a field. He/she put the tab keys. The focus is moved to the c field, and after that only the b field appears.

My question is: how to wait the b field appears before changing focusing, and so focusing on it, instead of c ?

0 Answers
Related