Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between the javascript/jQuery events "focus" and "focusin"?

What is the difference between these two events: focus and focusin?

like image 270
Randomblue Avatar asked Sep 05 '11 17:09

Randomblue


People also ask

What is the difference between focus and Focusin events in jQuery?

The focusin event fires when an element is about to receive focus. The main difference between this event and focus is that focusin bubbles while focus does not. The opposite of focusin is focusout . This event is not cancelable.

What is the difference between focus and blur in jQuery?

The blur event fires when an element has lost focus. The main difference between this event and focusout is that focusout bubbles while blur does not. The opposite of blur is focus . This event is not cancelable and does not bubble.

What is jQuery Focusin?

jQuery focusin() MethodThe focusin event occurs when an element (or any elements inside it) gets focus. The focusin() method attaches a function to run when a focus event occurs on the element, or any elements inside it. Unlike the focus() method, the focusin() method also triggers if any child elements get focus.

What is Focusin JavaScript?

JavaScript focus method is used to give focus to a html element. It sets the element as the active element in the current document. It can be applied to one html element at a single time in a current document. The element can either be a button or a text field or a window etc. It is supported by all the browsers.


2 Answers

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event, in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

This event will likely be used together with the focusout event.

like image 170
shabunc Avatar answered Sep 23 '22 02:09

shabunc


The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

http://api.jquery.com/focusin/

like image 35
Jared Farrish Avatar answered Sep 19 '22 02:09

Jared Farrish