源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> function leftAlign(){ document.getElementById('header').align="left"; } </script> </head> <body> <table width="100%" border="1"> <tr id="header"> <th>Firstname</th> <th>Lastname</th> </tr> <tr> <td>Peter</td> <td>Griffin</td> </tr> </table> <br> <input type="button" onclick="leftAlign()" value="內容向右對齊" /> <p><b>注意:</b>該實例不適用IE瀏覽器。</p> </body> </html>
運行結果