еще вариант в 1 проход
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
</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>
<script>
window.onload = function() {
var allTd = document.querySelectorAll("td"),
min,
max;
for (var i = 0, el; i < allTd.length; i += 1) {
el = allTd[i];
val = +el.innerHTML; //IE8
if (!min) {
max = {
val: val,
idx: i
};
min = {
val: val,
idx: i
};
} else {
if (val > max.val) {
max.val = val;
max.idx = i;
}
if (val < min.val) {
min.val = val;
min.idx = i;
}
}
}
allTd[min.idx].style.backgroundColor = "#FF0000";
allTd[max.idx].style.backgroundColor = "#008000"
};</script>
</body>
</html>