JavaScript HTML DOM中的nodeValue属性是什么意思?

原创
ithorizon 7个月前 (10-19) 阅读数 41 #HTML

nodeValue 属性用于获取节点值。您需要指定节点。

示例

您可以尝试运行以下代码来了解如何获取nodeValue属性。

直播演示

<!DOCTYPE html>
<html>
   <body>
      <p>Get the node value</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/c1c2c2ed740f" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">Java免费学习笔记(深入)</a>”;</p>
      <button>Demo Button Text</button>
      <script>
         var val = document.getElementsByTagName("BUTTON")[0];
         var res = val.childNodes[0].nodeValue;
         document.write("<br>Node Value: "+res);
      </script>
   </body>
</html>

以上就是JavaScript HTML DOM中的nodeValue属性是什么意思?的详细内容,更多请关注IT视界其它相关文章!



热门