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

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

示例

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

<!DOCTYPE html>
<html>
   <body>
      <p>Get the node value</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>