Does jQuery have any function to determine the tag type of the DOM element(s) referenced by jQuery object? I am writing a jQuery plugin and…
jQuery.fn.myPlugin() {
return this.each(function() {
var $this = $(this);
// <---------------------------------------HERE!
});
}
I would like to know if this is an <input> element or a <div> element, without directly using the DOM.
Do this:
…or to be safe, convert it to a specific case:
The
nodeNameproperty is a property that is widely supported and will give you the tag name in the case of an element node (as in your case).