HTML DOM id 属性

定义和用法

The id property sets or returns the id of a link element.

语法

  1. linkObject.id=id

实例

The following example outputs the id of a link element:

  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css"
  4. id="style1" href="try_dom_link.css" />
  5. </head>
  6. <body>
  7.  
  8. <script type="text/javascript">
  9. x=document.getElementById("style1");
  10. document.write("Id of link=" + x.id);
  11. </script>
  12.  
  13. </body>
  14. </html>