Javascript DOM CSS Style emptyCells Property

Introduction

Change how empty cells are shown:

Click the button to "hide" or "show" empty table-cells:

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, td {
  border: 1px solid black;
  margin: 15px;
}
</style>/*  w  ww.  ja v a  2s .  c o  m*/
</head>
<body>
<button type="button" onclick="hide()">Hide empty cells</button>
<button type="button" onclick="show()">Show empty cells</button>

<table id="myTable">
  <tr>
    <td>A</td>
    <td>B</td>
  </tr>
  <tr>
    <td>C</td>
    <td></td>
  </tr>
  <tr>
    <td></td>
    <td></td>
  </tr>
</table>
<script>
function hide() {
  document.getElementById("myTable").style.emptyCells = "hide";
}

function show() {
  document.getElementById("myTable").style.emptyCells = "show";
}
</script>

</body>
</html>

The emptyCells property sets or gets whether to show the border and background of empty cells.

Property Values

Value Description
showBorder and background are shown in empty cells. default
hideBorder and background are hidden in empty cells
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

The emptyCells property returns a String representing the border and background of empty cells.




PreviousNext

Related