Check for Empty Elements

Submitted by:James Anderson

Date added:13 February, 2011

Category:jQuery

Check for Empty Elements

Tags: jquery snippet , empty element , check element

Code Snippet:

//Do something for each empty element found:
$('*').each(function() {
if ($(this).text() == "") {
//Do Something
}
});

//TRUE or FALSE if element is empty:
var emptyTest = $('#myDiv').is(:empty);
 
 

Comments