JavaScript MouseEvent relatedTarget Property

You are Here:

JavaScript MouseEvent relatedTarget Property

The event.relatedTarget property returns the node name from which the mouse pointer comes from.

Note: This property is read-only.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <div> <p onmouseenter="myFunction(event)">Touch and go</p> </div> <h2>Related nodeName : <span id="point"></span></h2> <script> function myFunction(e){ var mynodeName= e.relatedTarget.nodeName ; document.getElementById("point").innerHTML = mynodeName; } </script> </body> </html>

Syntax

event.relatedTarget

Return Value

ValueExplanation
ObjectReturns an EventTarget object or null.

More Examples

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <div> <p>This is paragraph <span id="main" ionmouseenter="myFunction(event)">"Touch and go"</span></p> </div> <h2>Related nodeName : <span id="point"></span></h2> <script> function myFunction(e){ var mynodeName= e.relatedTarget.nodeName ; document.getElementById("point").innerHTML = mynodeName; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author