jQuery Focus Event

The focus event runs when an input, button, link, or another focusable control receives focus. It is useful for field guidance and accessible form feedback.

Syntax Top ↑

$( selector ).on( "focus", function (event) {
    // The element has received focus.
});

Show Guidance for Different Fields Top ↑

$( function () {
    $( "#t1" ).on( "focus", function () {
        $( "#d1" ).text( "Enter your name" );
    });

    $( "#t2" ).on( "focus", function () {
        $( "#d1" ).text( "Enter your email" );
    });
});

Open the focus-event demo →

Pair this topic with blur, which runs when focus leaves a control.

Form Component Events with jQuery






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer