<svg width="200" height="100">
<path id="myPath" d="M 0,30 h100" pathLength="50" />
</svg>SVGPathElement: pathLength property / notebook
SVGPathElement: pathLength property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const pathElement = document.getElementById("myPath");
// Access the pathLength property
const animatedNumber = pathElement.pathLength;
// The base value of the pathLength attribute
console.log(animatedNumber.baseVal); // Output: 100