event.relatedTarget
JQ Home <<
Objects <<
event.relatedTarget
Event related target property.
Description
The event.relatedTarget
Event object property, contains the value of the other DOM element, if it exists, involved in mouseoout
and mouseover
events.
Syntax
Signature | Description |
---|---|
event.relatedTarget | The value of the other DOM element, if it exists, involved in mouseoout and mouseover events. |
Parameters
None.
Return
A DOM element.
event.relatedTarget
Example
Objects << Top
Contains the value of the other DOM element, if it exists, involved in mouseoout
and mouseover
events.
In the example below when you enter or leave the 'div3' element the mouseover
and mouseout
JavaScript
events fire and we output the event.relatedTarget
as part of the message.
$(function(){
$('#div3').on({
'mouseover.ns1': function(event) {
$(this).css({backgroundColor: 'teal', color: 'black'})
.append('**entering "div3. " Related Target: ' + event.relatedTarget.<br/ >');
},
'mouseout.ns2': function(event) {
$(this).css({backgroundColor: 'blue', color: 'white'})
.append('**leaving "div3. " Related Target: ' + event.relatedTarget.<br/ >');
}
});
});
div3. Some initial text.
Related Tutorials
jQuery Advanced Tutorials - Lesson 5 - The Event Object