When using jQuery on
e.target
gives me the element which triggered the even but when using Bootstrap modal I access the triggering element via e.relatedTarget
. I would like to understand how they differ.
The relatedTarget
event target is used by some events to specify a secondary target and isn't specific to jQuery. On the other hand, target
will be used by most DOM events to specify the primary target of an event.
For instance, during focus
events, target
will be the element gaining focus, and relatedTarget
will be the element losing focus.
You can check out an exhaustive list of DOM events that specify a relatedTarget here: MouseEvent.relatedTarget.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With