jQuery focus | How to use focus event method to set focus in jQuery

jQuery focus method

Focus event happens when an element of HTML document gets focused by using mouse click or by using Tab key. At links (a href=””> the focus event occurs as its gets focus by using Tab key. Whereas form fields like text boxes, text area etc gets focus event as mouse is clicked into element.






Running example of focus method

In example below focus event is captured in two elements, one is text box and other is link. To check link focus use Tab key and for text box use either Tab or mouse click.

The text ahead of element will be shows as event occurs by using focus method of jQuery.

Experience this example online

Also see set focus with focus method() | jQueryblur

Was this article helpful?

Related Articles

Leave A Comment?