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
.
Access the tagName
property.
With JavaScript:
document.getElementById('elementID').tagName;
// or
document.querySelector('.elementClass').tagName;
With jQuery:
$('#elementID').prop('tagName');