SVGLength: valueInSpecifiedUnits プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

valueInSpecifiedUnitsSVGLength インターフェイスのプロパティで、 unitType で表現される単位で、浮動小数点の値を表します。

この属性を設定すると、 valuevalueAsString が自動的に更新され、この設定を反映します。

長さの数値係数を、浮動小数点数として指定します。

js
// SVGLength オブジェクトを取得
const svg = document.querySelector("svg");
const length = svg.createSVGLength();

// 長さの value を設定
length.value = 10;
console.log(length.valueInSpecifiedUnits); // 出力: 10

// 長さを数値係数で更新
length.valueInSpecifiedUnits = 20;
console.log(length.valueInSpecifiedUnits); // 出力: 20

仕様書

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGLength__valueInSpecifiedUnits

ブラウザーの互換性

関連情報