The SVG localName property returns localName of the given Attr element.
Syntax:
name = attribute.localName
Return value: This property returns the localName of the Attr.
Example 1:
<!DOCTYPE html>
<html>
<body>
<svg viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg">
<!-- A link around a text -->
<text id="example" x="20" y="20">
Click me
</text>
<script>
const element = document
.querySelector("#example");
const attribute = element.attributes[0];
console.log('LocalName is:',
attribute.localName);
</script>
</svg>
</body>
</html>
Output:


Example 2:
<!DOCTYPE html>
<html>
<body>
<svg viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg">
<!-- A link around a shape -->
<circle class="gfg" cx="20"
cy="20" r="15">
Click me
</circle>
<script>
const element = document.querySelector(".gfg");
const attribute = element.attributes[0];
console.log('LocalName is:', attribute.localName);
</script>
</svg>
</body>
</html>
Output:


Reference:https://developer.mozilla.org/en-US/docs/Web/API/Attr/localName