如何使用JavaScript设置表格中单元格之间的空间?
要使用JavaScript设置表中单元格之间的空间,请使用borderSpacing属性。使用此属性设置间距。
示例
您可以尝试运行以下代码以了解如何设置表单元格之间的空间-
<!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 set space between cells</button>
<script>
function display() {
document.getElementById("newTable").style.borderSpacing = "15px";
}
</script>
</body>
</html>热门推荐
10 新年祝福语简短的个性
11 剪简短的新年祝福语
12 哥哥病了祝福语大全简短
13 对司机的祝福语简短
14 结婚祝福语亲姐姐简短
15 结婚婚庆祝福语简短
16 毕业结婚祝福语简短精辟
17 送离职同事简短祝福语
18 小孩想说的祝福语简短