Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

SVG ownerElement Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The SVG ownerElement property returns ownerElement of the given Attr Element.

Syntax:

name = attribute.ownerElement

Return value: This property returns the ownerElement of the Attr.

Example 1:

HTML




<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 100 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <!-- A link around a text -->
        <text id="example" x="20" y="20">
            Click me
        </text>
          
        <script>
            const element = document
                .querySelector("#example");
                  
            const attribute = element.attributes[0];
            console.log(attribute.ownerElement);
        </script>
    </svg>
</body>
  
</html>

Output:


Example 2: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 100 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <!-- A link around a shape -->
        <circle id="example" cx="20" 
            cy="20" r="15">
            Click me
        </circle>
          
        <script>
            const element = document
                .querySelector("#example");
                  
            const attribute = element.attributes[0];
            console.log(attribute.ownerElement);
        </script>
    </svg>
</body>
  
</html>

Output:



My Personal Notes arrow_drop_up
Last Updated : 30 Mar, 2022
Like Article
Save Article
Related Tutorials