jQuery: Get selected element tag name

You can call .prop(“tagName”). Examples: jQuery(“<a>”).prop(“tagName”); //==> “A” jQuery(“<h1>”).prop(“tagName”); //==> “H1” jQuery(“<coolTagName999>”).prop(“tagName”); //==> “COOLTAGNAME999” If writing out .prop(“tagName”) is tedious, you can create a custom function like so: jQuery.fn.tagName = function() { return this.prop(“tagName”); }; Examples: jQuery(“<a>”).tagName(); //==> “A” jQuery(“<h1>”).tagName(); //==> “H1” jQuery(“<coolTagName999>”).tagName(); //==> “COOLTAGNAME999” Note that tag names are, by convention, returned CAPITALIZED. If … Read more