Select empty table cell

Description

The following code shows how to select empty table cell.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from   www  .j av a  2s  . co m-->
    $("td:empty").text("Was empty").css('background', 'rgb(255,220,200)');

  });
</script>
</head>
<body>
  <table>
    <tr>
      <td>data</td>
      <td>java2s.com</td>
    </tr>
    <tr>
      <td>data</td>
      <td></td>
    </tr>
    <tr>
      <td>data</td>
      <td></td>
    </tr>
  </table>

</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities