Home >>jQuery Tutorial >jQuery :empty Selector

jQuery :empty Selector

jQuery :empty Selector

jQuery :empty selector in jQuery is used to select empty elements without any text or child elements.

Syntax:
$(":empty")
Here is an Example of jQuery :empty Selector

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(":empty").css("background-color", "#97d7fc");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<table border="1">
<tr>
<th>S.no</th>
<th>Country</th>
</tr>
<tr>
<td>1</td>
<td>India</td>
</tr>
<tr>
<td>2</td>
<td>UK</td>
</tr>
<tr>
<td></td>
<td>Italy</td>
</tr>
<tr>
<td>4</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>Australia</td>
</tr>
<tr>
<td>6</td>
<td></td>
</tr>
<tr>
<td></td>
<td>Uk</td>
</tr>
<tr>
<td>8</td>
<td>Italy</td>
</tr>
<tr>
<td>9</td>
<td>France</td>
</tr>
</table>
</body>
</html>

Output:

Welcome to Phptpoint

S.no Country
1 India
2 UK
Italy
4
5 Australia
6
Uk
8 Italy
9 France