I want to know the tagName of the jquery object , i tried :
var obj = $("<div></div>");
alert($(obj).attr("tagName"));
This alert shows me undefined
. Whats wrong i am doing?
tagName
is a property of the underlying DOM element, not an attribute, so you can use prop
, which is the jQuery method for accessing/modifying properties:
alert($(obj).prop('tagName'));
Better, however, is to directly access the DOM property:
alert(obj[0].tagName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With