How to use Empty Selector Method in JQuery

This article describe about Empty Selector Method in JQuery.
  • 1649

Use :empty Selector method in jQuery

In this method , we select all empty elements.

The child elements and text elements are empty elements.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $(":empty").css("background-color", "blue");

    });

</script>

</head>

<body>

<h1>Welcome to This Page</h1>

<table>

<tr>

  <th>Student id</th>

  <th></th>

  <th>College</th>

</tr>

<tr>

<td>101</td>

<td>Aman</td>

<td></td>

</tr>

<tr>

<td>102</td>

<td></td>

<td>ARYAN</td>

</tr>

<tr>

<td>103</td>

<td>Vishu</td>

<td>BIT</td>

</tr>

<tr>

<td></td>

<td>Piyush</td>

<td>HIMT</td>

</tr>

<tr>

<td></td>

<td></td>

<td>UKL</td>

</tr>

</table>

</body>

</html>

Output

op1.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.