<table border="1" id="row">
<tr>
<td width="20" height="20"></td>
<td width="20" height="20"></td>
<td width="20" height="20">2</td>
<td width="20" height="20"></td>
</tr>
</table>
<script>
window.onload = function () {
arr= document.getElementById("row").getElementsByTagName("td");
colors= "red";
for (var i=0; i!= arr.length; ++i) {
if (typeof arr[i] !== "" && arr[i].innerHTML != "") {
arr[i].style.background=colors;
}
}
}
</script>