Skip to content
Related Articles

Related Articles

Improve Article

SVG LineElement.x2 Property

  • Last Updated : 03 Nov, 2020

The SVG LineElement.x2 property is used to return an SVGAnimatedLength object corresponding to the attribute of the given line element.

Syntax:

LineElement.x2

Return Value: This property returns an SVGAnimatedLength object that can be used to get the “x2” value and other properties of the line element.

Example 1: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
  
    <h3>SVG LineElement.x2 property</h3>
  
    <svg width="300" height="200" 
        xmlns="http://www.w3.org/2000/svg">
          
        <line x1="10" x2="100" y1="10" 
            y2="150" id="gfg" stroke="green" />
              
        <script>
            var g = document.getElementById("gfg");
            console.log(g.x2)
        </script>
    </svg>
</body>
  
</html>

Output:



Example 2: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
  
    <h3>SVG LineElement.x2 property</h3>
      
    <svg width="300" height="200" 
        xmlns="http://www.w3.org/2000/svg">
          
        <line x1="10%" x2="75%" y1="10%" 
            y2="25%" id="gfg" stroke="green" />
              
        <script>
            var g = document.getElementById("gfg");
            console.log(g.x2)
        </script>
    </svg>
</body>
  
</html>

Output:

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




My Personal Notes arrow_drop_up
Recommended Articles
Page :