javascript - Get element type using id or class - Stack Overflow

Is there a way to get the element type using an id or class with JQuery?With the HTML as <div id=&qu

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.

Share Improve this question asked Dec 13, 2015 at 2:22 ZomoXYZZomoXYZ 1,8811 gold badge22 silver badges47 bronze badges 3
  • 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
Add a ment  | 

1 Answer 1

Reset to default 6

Access 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

相关推荐

  • javascript - Get element type using id or class - Stack Overflow

    Is there a way to get the element type using an id or class with JQuery?With the HTML as <div id=&qu

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信