Is there a way to get the element type using an id or class with JQuery?
With the HTML as <div id="elementID"></div>
, using JQuery I want to return div
.
Is there a way to get the element type using an id or class with JQuery?
With the HTML as <div id="elementID"></div>
, using JQuery I want to return div
.
Questions that may already have your answer
section when writing my question.
– ZomoXYZ
Commented
Dec 13, 2015 at 2:29
site:
search feature helps quite a bit.
– user1106925
Commented
Dec 13, 2015 at 2:46
Access the tagName
property.
With JavaScript:
document.getElementById('elementID').tagName;
// or
document.querySelector('.elementClass').tagName;
With jQuery:
$('#elementID').prop('tagName');