Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SVG Element.attributes Property

  • Last Updated : 05 Nov, 2020

The SVG Element.attributes property returns an object that contains all the attributes of the given element.

Syntax:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

var attr = element.attributes

Return value: This property returns an object that contains all the attributes of the element.

Example 1: 



HTML




<!DOCTYPE html> 
<html
  
<body
    <svg width="350" height="350" 
        xmlns="http://www.w3.org/2000/svg">
        <a href="https://www.geeksforgeeks.org" id="gfg">
           <text x='100' y='100'>GfG</text>
        </a>
        <script>
           var g = document.getElementById('gfg');
           console.log(g.attributes)
        </script>
    </svg>
</body
  
</html>

Output:

Example 2: 

HTML




<!DOCTYPE html> 
<html
  
<body
    <svg width="350" height="350" 
         xmlns="http://www.w3.org/2000/svg">
        <a href="https://www.geeksforgeeks.org" id="gfg">
            <circle cx='100' cy='100' r="80"></circle>
        </a>
        <script>
            var g = document.getElementById('gfg');
            console.log(g.attributes)
        </script>
    </svg>
</body
  
</html>

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!