Select empty elements

Description

The following code shows how to select empty elements.

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() {<!-- ww  w .  j  a va  2s.  c o 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