Skip to content
Related Articles

Related Articles

HTML | DOM FocusEvent relatedTarget Property

View Discussion
Improve Article
Save Article
  • Last Updated : 14 Jul, 2022

The DOM FocusEvent relatedTarget Property is used to returns a name of the Element that is related to that element that triggered the focus/blur event. It is read only Property. 

  • For onfocus and onfocusin events, the related element is the element that LOST focus.
  • For onblur and onfocusout events, the related element is the element that GOT focus.



Return Value: It returns a reference to the related element or it returns a null if there is no related elements.


<!DOCTYPE html>
<body style="text-align:center;">
    <h1>GeeksForGeeks </h1>
    <h2>FocusEvent relatedTarget Property</h2>
    <textarea rows="4"
      Geeksforgeeks.It is a
      computer science portal for Geeks.
    <br> Input field:
    <input type="text"
    <p><b>First click on Textarea element
      and then click the Textarea Element</b></p>
        function RelatedElement(event) {
              "The related element that lost focus was: "
              + event.relatedTarget.tagName);

Output: Before focusing an element: 

After focusing an element: 

Supported Browsers: The browsers supported by DOM FocusEvent relatedTarget Property are listed below: 

  • Google Chrome 26
  • Edge 12
  • Internet Explorer 9.0
  • Firefox 24.0
  • Apple Safari 7
  • Opera 15
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!