The baseVal
property of the SVGAnimatedLength
interface contains the initial value of an SVG enumeration.
The baseVal
property of the SVGAnimatedLength
interface contains the initial value of an SVG enumeration.
A SVGLength
containing the initial value of the length.
html
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="200" height="200"> <circle cx="50" cy="50" r="20px" fill="gold" id="circle"></circle> </svg> <pre id="log"></pre>
js
const unit = [ "unknown", "", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc", ]; const circle = document.getElementById("circle"); const log = document.getElementById("log"); const baseValue = circle.r.baseVal.value; const baseUnit = unit[circle.r.baseVal.unitType]; log.textContent = `The 'circle.r.baseVal' is ${baseValue} (in ${baseUnit}).`;
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
baseVal |
1 | 12 | 1.5 | 9 | ≤12.1 | 3 | 3 | 18 | 4 | ≤12.1 | 1 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimatedLength/baseVal