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 |
瀏覽器相容性
載入中…