Skip to content
Related Articles

Related Articles

Improve Article

SVG Element.className Property

  • Last Updated : 03 Nov, 2020
Geek Week

The SVG Element.className property is used to return the className of the given Element.

Syntax:

var cName = element.className

Return value: This property returns the className 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" class="Geeks">
  
            <text x='100' y='100' 
                font-size="50px">GfG
            </text>
        </a>
          
        <script>
            var g = document.getElementById('gfg');
            console.log(g.className)
        </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" class="geeks">
              
            <circle cx='100' cy='100' r="80"></circle>
        </a>
        <script>
            var g = document.getElementById('gfg');
            console.log(g.className)
        </script>
    </svg>
</body>
  
</html>

Output:

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :