源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> function rowRules(){ document.getElementById('myTable').rules="rows"; } function colRules(){ document.getElementById('myTable').rules="cols"; } </script> </head> <body> <table id="myTable" border="1"> <tr> <td>行1 列1</td> <td>行1 列2</td> </tr> <tr> <td>行2 列1</td> <td>行2 列2</td> </tr> <tr> <td>行3 列1</td> <td>行3 列2</td> </tr> </table> <br> <input type="button" onclick="rowRules()" value="只顯示行邊框"> <input type="button" onclick="colRules()" value="至顯示列邊框"> </body> </html>
運行結果