HTML DOM name 属性

定义和用法

name 属性可设置或返回按钮的名称。

语法

  1. buttonObject.name=name

实例

下面的例子可返回按钮的名称:

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