<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<table>
<tr>
<td id = "num1"><p class = "text">2</p></td>
<td id = "num2"><p class = "text">0</p></td>
<td id = "num3"><p class = "text">2</p></td>
<td id = "num4"><p class = "text">-2</p></td>
</tr>
</table>
<script>
var p = document.querySelectorAll('td p');
for (var i=0; i<p.length; i++) {
p[i].style.color = "blue";
}
for (var i=0; i>p.length; i++) {
p[i].style.color = "green";
}
</script>
</body>
</html>