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
.
- 1 google./… – user1106925 Commented Dec 13, 2015 at 2:27
-
1
@squint I looked it up on Google, I couldn't find a thing. I wonder why it didn't show up in my search or in the
Questions that may already have your answer
section when writing my question. – ZomoXYZ Commented Dec 13, 2015 at 2:29 -
1
No problem. I just like to show people the search I used to find answers. Figure it'll help next time. Using the
site:
search feature helps quite a bit. – user1106925 Commented Dec 13, 2015 at 2:46
1 Answer
Reset to default 6Access the tagName
property.
With JavaScript:
document.getElementById('elementID').tagName;
// or
document.querySelector('.elementClass').tagName;
With jQuery:
$('#elementID').prop('tagName');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745115071a4612079.html
评论列表(0条)