event.relatedTarget() Property - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:event.relatedTarget


The event.relatedTarget property returns which element being entered or exited during mouse movement.


Parameter Require Description
event Required.The event parameter comes from the event binding function

The following code shows how to Return the related target of an element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    $("div, p").mouseenter(function(event){
        $("#msg").html("Related target is: " + event.relatedTarget.nodeName);
    });/*from  ww w  . j  av  a 2s  . c  o m*/

<div style="height:200px;border:solid">This is a div element
  <p style="background-color:pink">This is a paragraph</p>

<div id="msg">

<div style="height:200px;border:solid">This is a div element
  <span style="background-color:blue">This is a span</span>


Related Tutorials