Home >>jQuery Tutorial >jQuery event.relatedTarget Property

jQuery event.relatedTarget Property

jQuery event.relatedTarget Property

The event.relatedTarget property in jQuery is used to returns the element that is being exited or entered on mouse movement

Syntax:
event.relatedTarget

Parameter Values

Parameter Description
event It is a required parameter and is used to specify the event parameter comes from the event binding function
Here is an Example of jQuery event.relatedTarget Property:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".box, .txt").mouseenter(function(event){
$("#output").html("Related target is: " + event.relatedTarget.nodeName);
});
});
</script>
</head>
<body>
<div class="box" style="height:180px;border:solid">This is a div element 
  <p class="txt" style="background-color:orange">This is a paragraph</p>
</div><br>
<div id="output" />
</body>
</html>

Output:
This is a div element

This is a paragraph



No Sidebar ads