I am trying to check if the element is empty.
My element could be something like
<table>
<td> </td>
<td> </td>
<td> </td>
<td>text</td>
</table>
I have tried:
$('table td').each(function(){
if($(this).is(':empty')){
console.log('found;)
}
})
and
$('table td').each(function(){
if($(this).html()==' '){
console.log('found')
}
})
but I can't seem to find it. Anyway I can accomplish this? Thanks a lot!
Try using $.trim
like below,
$.trim($(this).text()) === ''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With