How to find the tag name by reference?

var someTag = document.getElementById ("someID");

How to find the name of the tag link someTag?

  • one
    Open the JavaScript console for example in Chrome, enter there var someTag = document.getElementById ("someID"); Press the Enter key, then enter someTag in the console. auto-completion of the code will automatically show a list of all the properties and methods of the object, look carefully at them, in the future it may come in handy. Among all this heap, you will see the tagName , that is: someTag.tagName - ReinRaus
  • thank. great addition! - nullptr 3:51 pm

1 answer 1

There is a TagName property

  • element.tagName - javascript is case sensitive - istem