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>

更新于: 22-5-2020

213 次浏览

开启你的职业生涯

通过完成课程获得认证

立即开始
广告
© . All rights reserved.