若要设置是否折叠表格边框,请使用 borderCollapse属性并将其设置为折叠。您可以尝试运行以下代码来将表格边框设置为折叠-
<!DOCTYPE html> <html> <body> <table id="newTable" border="2"> <tr> <th>EmpID</th> <th>EmpName</th> <th>EmpDept</th> </tr> <tr> <td>001</td> <td>Amit</td> <td>IT</td> </tr> <tr> <td>002</td> <td>John</td> <td>Finance</td> </tr> <tr> <td>003</td> <td>David</td> <td>Marketing</td> </tr> </table> <br> <button onclick="display()">Click to collapse</button> <script> function display() { document.getElementById("newTable").style.borderCollapse = "collapse"; } </script> </body> </html>