You could do something like this:
<!DOCTYPE html>
<html>
<head>
<title>Change HTML class</title>
<style>
.test p
{
color:blue;
}
.done p
{
color:red;
}
</style>
<script >
function change_class_name() {
var els = document.getElementsByClassName('halo');
els[0].parentElement.parentElement.className = 'done';
}
</script>
</head>
<body onload="javascript:change_class_name()">
<table>
<tr>
<td class="test">
<div>
<div class="halo">
<p>Hello World</p>
</div>
</div>
</td>
<td class="test">
<div>
<div class="hai">
<p>Hello World</p>
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
When you should call the function change_class_name() is up to you.