Sometimes, we want to get the selected element type with JavaScript.
In this article, we’ll look at how to get the selected element type with JavaScript.
How to get the selected element type with JavaScript?
To get the selected element type with JavaScript, we use the tagName
property.
For instance, we write
const elementType = document.getElementById("born").tagName;
to get the element with getElementById
.
Then we use the tagName
property to get a string with the element type.
Conclusion
To get the selected element type with JavaScript, we use the tagName
property.