To get an HTML element’s TagName in jQuery, you don’t need a specific function. For instance, if you have an element with id=”footer”, to get the footer tag name, all you need to do is:
var footerTagName = $("#footer").tagName;
As you can see, sometimes by default, JavaScript could handle things without the need of a library.











































#1 by chitown on March 11, 2010 - 3:17 pm
I think that should be…
var footerTagName = jQuery(‘#footer’)[0].tagName;
— or —
var footerTagName = jQuery(‘#footer’).get(0).tagName;
#2 by mjgs on May 13, 2010 - 12:06 pm
var footerTagName = jQuery(‘#footer’).attr(‘tagName’)