I have a jQuery selection, is there a way to determine what type of element it is (e.g. <a>,<span>,etc...)?
Asked
Active
Viewed 1,147 times
2 Answers
3
You can use .is()
with a selector to see it it matches, like this:
var is_span = $(this).is("span");
Or if you have a DOM element:
var is_span = this.tagName == "SPAN";

Nick Craver
- 623,446
- 136
- 1,297
- 1,155