dom - How can I determine the type of an HTML element in JavaScript? -


i need way determine type of html element in javascript. has id, element div, form field, fieldset, etc. how can achieve this?

nodename attribute looking for. example:

var elt = document.getelementbyid('foo'); console.log(elt.nodename); 

note nodename returns element name capitalized , without angle brackets, means if want check if element <div> element follows:

elt.nodename == "div" 

while not give expected results:

elt.nodename == "<div>" 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -