利用 JavaScript 如何更改表格边框的宽度?
若想更改表格边框的宽度,请使用 DOM border 属性。可以尝试运行以下代码,在 JavaScript 中更改表格边框的宽度 -
示例
<!DOCTYPE html> <html> <head> <script> function borderFunc(x) { document.getElementById(x).style.border = "5px dashed blue"; } </script> </head> <body> <table style = "border:2px solid black" id = "newtable"> <tr> <td>One</td> <td>Two</td> </tr> <tr> <td>Three</td> <td>Four</td> </tr> <tr> <td>Five</td> <td>Six</td> </tr> </table> <p> <input type = "button" onclick = "borderFunc('newtable')" value = "Change Border Width"> </p> </body> </html>
广告