admin管理员组文章数量:1435859
I know you can do this, but every time I Google it I get how to select all elements of a certain tag.
So, e.g.:
alert($('#my-wrapper').someJSMethod());
{...}
<div id="my-wrapper"></div>
Would alert "DIV" actually. I'm selecting elements with jQuery by the way.
I know you can do this, but every time I Google it I get how to select all elements of a certain tag.
So, e.g.:
alert($('#my-wrapper').someJSMethod());
{...}
<div id="my-wrapper"></div>
Would alert "DIV" actually. I'm selecting elements with jQuery by the way.
Share Improve this question asked Jun 28, 2010 at 23:11 Oscar GodsonOscar Godson 32.8k42 gold badges125 silver badges206 bronze badges2 Answers
Reset to default 9You can do this:
alert($('#my-wrapper').get(0).nodeName);
//or:
alert($('#my-wrapper')[0].nodeName);
Or, no need for jQuery:
alert(document.getElementById('my-wrapper').nodeName);
$('#my-wrapper')[0].tagName
本文标签: jqueryGet the selected element39s HTML Tag in JavaScriptStack Overflow
版权声明:本文标题:jquery - Get the selected element's HTML Tag in JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745666857a2669338.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论