HTML DOM rules 属性

定义和用法

rules 属性可设置或返回表格的内部边线。

语法

  1. tableObject.rules=none|groups|rows|cols|all

实例

下面的例子设置了表格的两种不同的内部边线:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function rowRules()
  5. {
  6. document.getElementById('myTable').rules="rows"
  7. }
  8. function colRules()
  9. {
  10. document.getElementById('myTable').rules="cols"
  11. }
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <table id="myTable" border="1">
  17. <tr>
  18. <td>Row1 cell1</td>
  19. <td>Row1 cell2</td>
  20. </tr>
  21. <tr>
  22. <td>Row2 cell1</td>
  23. <td>Row2 cell2</td>
  24. </tr>
  25. <tr>
  26. <td>Row3 cell1</td>
  27. <td>Row3 cell2</td>
  28. </tr>
  29. </table>
  30. <br />
  31. <input type="button" onclick="rowRules()"
  32. value="Show only row borders">
  33. <input type="button" onclick="colRules()"
  34. value="Show only col borders">
  35.  
  36. </body>
  37. </html>