Reputation: 24052
So I have this div on my page:
<div id="valueTableBTS"></div>
This div gets filled with an html table dynamically. What I want to be able to do in JQuery is to check if this table has any empty cells, so I know if I need to keep calling my other method to fill it with any newly grabbed values.
How would I do that?
Upvotes: 2
Views: 3393
Reputation: 40673
After the table is inserted, you could iterate through the TDs:
$('.yourTable td').each(function(){
if ($(this).text=""){
//it's blank
}
})
Upvotes: 0
Reputation: 235972
If I get you right, this should do it:
if( $('#valueTableBTS tbody').find('td:empty').length ) {
// at least one <td> is empty
}
Demo: http://jsfiddle.net/p53Y8/
The :empty
help selector will find nodes which have no children (including text nodes).
Upvotes: 1
Reputation: 16953
if ($("#valueTableBTS").children(".cellClass").length == 0) {
//blah
}
Upvotes: 0