为什么这里不能通过getAttribute()方法获取nodeName属性值?
尼古拉阿列克塞耶维奇奥斯特洛夫斯基
尼古拉阿列克塞耶维奇奥斯特洛夫斯基 2016-12-21 11:15:48
0
2
749

为什么这里不能通过getAttribute()方法获取nodeName属性值?


尼古拉阿列克塞耶维奇奥斯特洛夫斯基
尼古拉阿列克塞耶维奇奥斯特洛夫斯基

reply all(2)
数据分析师

Why can’t the nodeName attribute value be obtained through the getAttribute() method here? -PHP Chinese website Q&A-Why can't the nodeName attribute value be obtained through the getAttribute() method here? -PHP Chinese website Q&A

Please watch and learn.

巴扎黑

getAttribute()方法只能获取元素中已存在属性的属性值,而nodeName是每一个节点自带的静态属性而不是我们自己定义的属性,所以不能使用getAttribute()方法获取nodeName属性值

例如:<p class="message" id="text" width="200px" height="50px">这是一个p标签</p>

我们可以使用getAttribute()方法获取class、id、width、height等属性的属性值,但不可以使用getAttribute()方法获取nodeName属性值,因为我们没用写一个className属性


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!