jQuery :empty Selector

The jQuery :empty selector selects all the elements which are empty and contains no child items. If you want to find the empty items from the group element which contains no text content, you can use this selector.

Syntax of jQuery :empty Selector

The syntax of jQuery :empty Selector is given below.


It requires no parameter as an argument to select the required element. However, you can use the tag name to find the emptiness of only the matching element. By default, it selects all the elements which are empty and contains no child elements.

Let’s find out the use of it more clear with the example given below.

Select Empty Table Cells with jQuery :empty Selector

If you want to find the table cells which contain no text content. You can use the below example which highlights the empty cell by applying the background color. The example uses the click event to select the empty item.


Test it Live


Sr No Name
1 Table
2 Chair
3 Dining Table
5 Almirah

The above example contains a button and a table. If you find it difficult to identify the empty cell, you can click the above button to get it highlighted. When you click the above button, it applies the ‘orange’ background color the selected cell.

Add Class to Empty Elements

To use the jQuery :empty selector with elements other than a table. You can use the class name to add to the empty element to find it. There are many HTML p elements in the below example and you have to get the empty item. All these items are inside the HTML div element.


Test it Live


Welcome to Tutorialdeep!

Learn jQuery from live examples.

Use codes anywhere on your project.

Click the button given in the above example to add the class to the empty element. If you want more details on how to add class, you can our post based on add class on hover and remove on mouseout using jQuery. The class added to the empty element applies the background color.

I hope, you like the example given in this post. If you have any queries regarding the tutorial, please comment below. Also tell me, what other methods you are using with the jQuery :empty selector.