What is the best way to get an element’s tag name in JS?

nodeName is the most consistent here. I would suggest you take a minute and read this post for a few differences and inconsistencies with tagName if you’re more curious as to why.

For the prototype part of the question…it’s a JavaScript property, just this.nodeName should work or element.nodeName, whatever your element’s called in the current function should work.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)