Set the borderCollapse property: - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderCollapse

Description

Set the borderCollapse property:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
td, th {
    border: 1px solid black;
}
</style>//ww w  .ja va 2s.c o  m
</head>
<body>

<table id="myTable" style="border-collapse:collapse;">
  <tr>
    <th>Month</th>
    <th>Dollor</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$150</td>
  </tr>
</table>
<br>

<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("myTable").style.borderCollapse = 'separate';
}
</script>

</body>
</html>

Related Tutorials