 <p>Instead of checking the empty value it's better to check the length of the content</p> <pre><code>$("td").hover(function(){ var cell = $(this).html(); if(cell.length===0) $(this).css( "background-color", "orange"); else $(this).css( "background-color", "black"); }); </code></pre>