How to know whether the border and background of empty cells are hidden or not with JavaScript?

JavascriptWeb DevelopmentFront End Scripts

To know whether the background and border of empty cells are hidden in JavaScript, use the emptyCells property.

Example

You can try to run the following code to set whether to show the border and background of empty cells or not with JavaScript −

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, td {
            border:1px solid;
         }
      </style>
   </head>
   <body>
      <table id="myID" style="empty-cells:hide;">
         <tr>
            <td>One</td>
            <td>111</td>
         </tr>
         <tr>
            <td>Two</td>
            <td>222</td>
         </tr>
         <tr>
            <td>Three</td>
            <td></td>
         </tr>
      </table>
      <br>
      <button type="button" onclick="display()">Return</button>
      <script>
         function display() {
            document.write(document.getElementById("myID").style.emptyCells);
         }
      </script>
   </body>
</html>
raja
Published on 27-Feb-2018 12:23:21
Advertisements