HTML DOM localName property
Last Updated :
11 Jul, 2022
The HTML DOM localName property returns the local name of an element. This is a read only property.
Syntax:
element.localName
Return Value: A String representing the local Name of the element.
Example:
The following example shows how to get localName of an element using this property.
html
< html >
< head >
< title >GeeksforGeeks</ title >
< h1 id="d">GeeksforGeeks</ h1 >
< button id="btn">Click Here</ button >
< script >
const element = document.getElementById("btn");
const di=document.getElementById("d");
element.addEventListener("click", function() {
console.log(di.localName);
console.log(element.localName);
});
</ script >
</ head >
</ html >
|
Output:
Before Button Click:
After Button Click:
In console the local names of the following elements can be seen.
Supported Browsers:
- Google Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 9 and above
- Opera 12.1 and above
- Safari 1 and above
Share your thoughts in the comments
Please Login to comment...