jazzblue
jazzblue

Reputation: 2437

Determine object's tag in jQuery

Suppose I have a jQuery object, say it is field of a form and I query it by id:

$("#my_field")

How can I determine the tag of that object, in particular: is it label or input?

Upvotes: 2

Views: 30

Answers (1)

Sushanth --
Sushanth --

Reputation: 55750

You can use the tagName property on a DOM object

Accessing jQuery object by index gives you the DOM object.

$('#my_field')[0].tagName

Check Fiddle

Upvotes: 3

Related Questions