HTML DOM value 属性

定义和用法

value 属性设置或返回显示在按钮上的文本。

语法

  1. buttonObject.value=value

实例

下面的例子可返回显示在按钮上的文本:

  1. <html>
  2. <body>
  3.  
  4. <input type="button" id="button1" name="button1" value="Click Me!" />
  5.  
  6. <p>The text on the button is:
  7. <script type="text/javascript">
  8. x=document.getElementById('button1');
  9. document.write(x.value);
  10. </script></p>
  11.  
  12. </body>
  13. </html>