Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

SVG AElement.href Property

  • Last Updated : 05 Nov, 2020

The SVG AElement.href property returns an SVGAnimatedLength object corresponding to the attribute of the given A 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.

AElement.href

Return value: This property returns SVGAnimatedLength object that can be used to get the href of the AElement.

Example 1: 






<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 100 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <!-- A link around a shape -->
        <a href="https://www.geeksforgeeks.org" id="gfg">
            <circle cx="20" cy="40" r="15" />
        </a>
          
        <script>
            var g = document.getElementById("gfg");
            console.log(g.href);
        </script>
    </svg>
</body>
  
</html>

Output:

Example 2: 




<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 100 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <!-- A link around a text -->
        <a href="https://www.geeksforgeeks.org" id="gfg">
            <text x="40" y="20" text-anchor="middle">
                <gfg>
            </text>
        </a>
          
        <script>
            var g = document.getElementById("gfg");
            console.log(g.href);
        </script>
    </svg>
</body>
  
</html>

Output:

Reference: https://developer.mozilla.org/en-US/docs/Web/API/SVGAElement




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!