Check if the selected element contains white space

html, jquery

Solution

Try using `$.trim` like below,

$.trim($(this).text()) === ''

Problem

I am trying to check if the element is empty. My element could be something like ``` <table> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</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()=='&nbsp;'){ console.log('found') } }) ``` but I can't seem to find it. Anyway I can accomplish this? Thanks a lot!

Original source