Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between e.target and e.relatedTarget?

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.

like image 444
Alexander Suraphel Avatar asked Feb 06 '17 07:02

Alexander Suraphel


1 Answers

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.

like image 96
lleaff Avatar answered Oct 23 '22 05:10

lleaff