10 09/2014

jquery attr tagName

最后更新: Wed Sep 10 2014 12:37:50 GMT+0800

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);

Or

alert(obj.get(0).nodeName);