SVGTextContentElement: textLength プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
textLength
は SVGTextContentElement
インターフェイスの読み取り専用プロパティで、この要素の textLength
属性を反映します。
値
例
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");
// textLength プロパティへのアクセス
const animatedLength = textElement.textLength;
// textLength 属性の元値
console.log(animatedLength.baseVal.value); // 出力: 100
仕様書
Specification |
---|
Scalable Vector Graphics (SVG) 2 # __svg__SVGTextContentElement__textLength |