简体   繁体   中英

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

这两个事件有什么区别: focusfocusin

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.

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/

According to the jQuery focusin documentation :

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).

The focusin events bubble, the focus events doesn't. That means that you can use the focusin on the parent element of a form field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM