本文介绍了.tagName和.nodeName之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$('this')[0] .nodeName
和 $('this')[0] .tagName有什么区别?
?
推荐答案
专用于元素节点(类型1节点)获取元素的类型。
The tagName
property is meant specifically for element nodes (type 1 nodes) to get the type of element.
有几个。
There are several other types of nodes as well (comment, attribute, text, etc.). To get the name of any of the various node types, you can use the nodeName
property.
当使用 nodeName
>元素节点,你会得到它的标签名称,所以可以真的被使用,虽然你会得到使用 nodeName
。
When using nodeName
against an element node, you'll get its tag name, so either could really be used, though you'll get better consistency between browsers when using nodeName
.
这篇关于.tagName和.nodeName之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!