gbd
gbd

Reputation: 213

How to check what an element is if we only know its ID?

If we only know the ID of an element, is it possible to check using javascript or jQuery what kind of an element it is, whether its textarea, div, span or something else?

Upvotes: 1

Views: 131

Answers (2)

Srinu Chinka
Srinu Chinka

Reputation: 1491

By using jQuery:

$("#someid").prop("tagName");

By using JavaScript:

document.getElementById("someid").tagName;

Upvotes: 7

Bogdan Kuštan
Bogdan Kuštan

Reputation: 5577

document.querySelector('#id').nodeName

Upvotes: 1

Related Questions