SVG
The pathLength read-only property of the SVGPathElement interface reflects the pathLength attribute of the given path element.
Value
An SVGAnimatedNumber.
Examples
Accessing the pathLength Property
<svg width="200" height="100">
<path id="myPath" d="M 0,30 h100" pathLength="50" />
</svg>
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
Specifications
Browser compatibility
See also
- SVGGeometryElement.pathLength
- pathLength
- SVGAnimatedLength
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
