вариант с 1 циклом
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.max {
background-color: #FF0000;
}
.min{
background-color: #008000;
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
for (var d = document.querySelectorAll("td"), c = 0; c < d.length; c++) {
var b = d[c],
a = document.querySelector(".max") || b;
+a.textContent < +b.textContent && (a.classList.remove("max"), a = b);
a.classList.add("max");
a = document.querySelector(".min") || b;
+a.textContent > +b.textContent && (a.classList.remove("min"), a = b);
a.classList.add("min")
}
});
</script>
</head>
<body>
<table>
<tr>
<td>11</td>
<td>22</td>
<td>65</td>
<td>14</td>
<td>35</td>
</tr>
<tr>
<td>39</td>
<td>12</td>
<td>84</td>
<td>45</td>
<td>38</td>
</tr>
<tr>
<td>37</td>
<td>39</td>
<td>52</td>
<td>38</td>
<td>24</td>
</tr>
</table>
</body>
</html>