добавить проверок
<style>
td {
border: solid 1px;
}
</style>
<table>
<tr id="a00">
<td>11</td>
<td>12</td>
</tr>
<tr id="a01">
<td>21</td>
<td>22</td>
</tr>
<tr id="a02">
<td>31</td>
<td>32</td>
</tr>
<tr id="a03">
<td>41</td>
<td>42</td>
</tr>
<tr id="a04">
<td>51</td>
<td>52</td>
</tr>
</table>
<button>hide</button>
<button>show</button>
<script>
window.onload = function () {
var elems = document.body.children;
var rows = elems[0].rows;
var len = rows.length;
for (var i = 0; i < len; i++) {
rows[i].style.display = 'block';
}
function sh(first, last, mode) {
var l = last - first;
if (l < len) {
var disp;
if (mode == 'hide') {
disp = 'none';
} else {
disp = 'block';
}
for (var i = first; i <= l; i++) {
if (rows[i].style.display != disp) {
rows[i].style.display = disp;
}
}
}
}
elems[1].onclick = function () {
var first = prompt('first', 1);
var last = prompt('last', 2);
sh(first, last, 'hide');
}
elems[2].onclick = function () {
var first = prompt('first', 1);
var last = prompt('last', 2);
sh(first, last, 'show');
}
}
</script>