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:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div, p").mouseenter(function(event){ $("#msg").html("Related target is: " + event.relatedTarget.nodeName); });/*from ww w . j av a 2s . c o m*/ }); </script> </head> <body> <div style="height:200px;border:solid">This is a div element <p style="background-color:pink">This is a paragraph</p> </div><br> <div id="msg"> <div style="height:200px;border:solid">This is a div element <span style="background-color:blue">This is a span</span> </div><br> </body> </html>