Skip to content
Related Articles

Related Articles

SVG CircleElement.cx Property
  • Last Updated : 21 Dec, 2020

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

Syntax:

CircleElement.cx

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

Example 1: 

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 250 250" width="250" 
        height="250">
          
        <circle cx="100" cy="100" r="50" 
            fill="green" id="gfg" 
            onclick="clickCircle();" />
          
        <script>
            var g = document.getElementById("gfg");
            console.log(g.cx)
        </script>
    </svg>
</body>
  
</html>

chevron_right


Output:



Example 2: 

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 250 250" width="250" 
        height="250">
          
        <circle cx="100" cy="100" r="50" 
            fill="green" class="gfg" 
            onclick="clickCircle();" />
          
        <script>
            function clickCircle() {
                var g = document.querySelector(".gfg");
                document.write("cx value of the circle is : ",
                    g.cx.animVal.value);
            }
        </script>
    </svg>
</body>
  
</html>

chevron_right


Output:

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :