Binding jQuery handlers during the event capture phase (not an event bubble)

I want to implement event delegation on blur / focus events, similar to the way it is suggested on quirksmode . As explained in the TFA, the blur and focus events do not bubble, so you cannot use event delegation with them in the bubbling phase, but you can capture them in the capture phase (human, javascript events are weird).

Anyway, as far as I can see, jQuery events all refer to the bubbling phase, or at least to the one where I always used them. I don't see any information about this anyway in jQuery docs and by default uses something like $ ('# foo'). Blur (blurHandler) doesn't seem to capture it.

I would rather use jQuery for consistency; is there any way to do this?

+3
source share
1 answer

If you say you want the container to start the handler when the child <input>receives focus or blur, try using .focusin()and .focusout().

From the docs:

The focusin event is dispatched to an element when it or any element inside it receives focus. This differs from a focal event in that it supports focus event detection on parent elements.

, . , ( , ).

+3

Source: https://habr.com/ru/post/1759542/


All Articles