源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>开源教程(ossoft.cn)</title> <script> function padding(){ document.getElementById('myTable').cellPadding="15"; } function spacing(){ document.getElementById('myTable').cellSpacing="15"; } </script> </head> <body> <table id="myTable" border="1"> <tr> <td>100</td> <td>200</td> </tr> <tr> <td>300</td> <td>400</td> </tr> </table> <br> <input type="button" onclick="padding()" value="修改单元格边距"> <input type="button" onclick="spacing()" value="修改单元格间距"> </body> </html>
运行结果