Open In App

SVG Element.classList Property

Improve
Improve
Like Article
Like
Save
Share
Report

The SVG Element.classList property returns the classList of the given element.

Syntax:

var attr = element.classList

Return value: This property returns classList 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.classList)
        </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.classList)
        </script>
    </svg>
</body>
  
</html>


Output:



Last Updated : 30 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads