Javascript examples for jQuery Selector:empty
The :empty selector selects empty elements, which have no child elements or text.
The following code shows how to select all empty elements:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(":empty").css("background-color", "yellow"); });//ww w . j av a 2 s.c o m </script> </head> <body> <h1>Welcome to My Web Page</h1> <table border="1"> <tr> <th>Company</th> <th></th> <th>Country</th> </tr> <tr> <td>A</td> <td>B</td> <td></td> </tr> <tr> <td>C</td> <td></td> <td>D</td> </tr> <tr> <td>E</td> <td>F</td> <td>G</td> </tr> </table> </body> </html>