O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Focus Changes

$("input").on("focus",   function(e){     gain_focus_code_here }); $("input").on("blur",   function(e){     lose_focus_code_here });

When handling form events, two important events are focus and blur. These events are triggered when a form element receives or loses focus. There is a lot that you can use these events for. For instance, you might want to change the look and feel of a form element when it gains focus or loses focus.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required