Javascript DOM CSS Style borderSpacing Property get

Introduction

Return the space between cells in a table:

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<table id="myTable" border="1" style="border-spacing:10px;">
  <caption id="myCaption">Monthly Salary</caption>
  <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>/*from  w  ww . j  a v  a2 s.c om*/
<br>

<button type="button" onclick="myFunction()">Return the space between the cells in the table</button>

<script>
function myFunction() {
  alert(document.getElementById("myTable").style.borderSpacing);
}
</script>

</body>
</html>



PreviousNext

Related