Open In App

SVG EllipseElement.cx Property

Last Updated : 30 Mar, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

The SVG EllipseElement.cx property returns an SVGAnimatedLength object corresponding to the attribute of the given ellipse element

Syntax:

EllipseElement.cx

Return value: This property returns SVGAnimatedLength object that can be used get the cx of the Ellipse element

Example 1: 

HTML
<!DOCTYPE html>
<html>

<body>
    <svg width="200" height="200" 
        xmlns="http://www.w3.org/2000/svg">
        
        <ellipse cx="100" cy="100" rx="100" 
            ry="60" id="ellipse" 
            onclick="outputSize();" />
            
        <script>
            var g = document.getElementById("ellipse");
            console.log(g.cx)
        </script>
    </svg>
</body>

</html>

Output:

Example 2:

HTML
<!DOCTYPE html>
<html>

<body>
    <svg width="300" height="200" 
        xmlns="http://www.w3.org/2000/svg">
        
        <ellipse cx="150" cy="100" rx="100" 
            ry="60" id="ellipse" 
            onclick="outputSize();" />
            
        <script>
            var g = document.getElementById("ellipse");
            console.log(g.cx)
        </script>
    </svg>
</body>

</html>

Output:


Next Article

Similar Reads

  翻译: