SVGTextContentElement:textLength 属性
SVGTextContentElement
接口的只读属性 textLength
反映了给定元素的 textLength
属性。
值
一个 SVGAnimatedLength
对象。
示例
访问 textLength 属性
html
<svg width="200" height="100">
<text id="myText" x="10" y="50" textLength="100" lengthAdjust="spacing">
Hello, SVG!
</text>
</svg>
js
const textElement = document.getElementById("myText");
// Access the textLength property
const animatedLength = textElement.textLength;
// The base value of the textLength attribute
console.log(animatedLength.baseVal.value); // Output: 100
规范
规范 |
---|
Scalable Vector Graphics (SVG) 2 # __svg__SVGTextContentElement__textLength |
浏览器兼容性
加载中…