<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
var a = [].slice.call(document.querySelectorAll("td"), 0);
a.sort(function(a, b) {
return b.textContent - a.textContent
});
a[0].style.backgroundColor = "#FF0000";
a.slice(-1)[0].style.backgroundColor = "#008000"
});
</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>