Javascript DOM CSS Style borderCollapse Property get

Introduction

Return the borderCollapse property:

alert(document.getElementById("myTable").style.borderCollapse);

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
td, th {
  border: 1px solid black;
}
</style>//from  w  w  w. java  2s . co  m
</head>
<body>

<table id="myTable" style="border-collapse:collapse;">
  <tr>  <th>Item</th>    <th>Savings</th>  </tr>
  <tr>  <td>CSS</td>     <td>$100</td>     </tr>
  <tr>  <td>HTML</td>    <td>$50</td>      </tr>
</table>
<br>

<button type="button" onclick="myFunction()">Return border collapse</button>

<p id="demo"></p>

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

</body>
</html>



PreviousNext

Related