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:
<!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:
<!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: