I am trying to delete multiple columns from html table using javascript. The approach it is using is that it searches in top row for tag "<span></span>", if found, then it deletes that whole column. Column can be any which has empty span tags. It is working if it does not has any colspan or rowspan tag. But not working in vice-versa case.
The below table is just a short example, although I have attached the image of actual table I am working on.

The catch here is "rowspan" and "colspan" which makes it a little tricky.
Here is my code
<!DOCTYPE html>
<html>
<body>
<table style="width:100%" border='1' id='Just_for_california'>
<tr>
<td rowspan='2'><span></span></td>
<td>S</td>
<td><span></span></td>
</tr>
<tr>
<td colspan='2'>Jackson</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
<script>
var table = document.getElementById('Just_for_california'),
rows = table.rows;
for (var i = 0; i < rows[0].cells.length; i++) {
var str = rows[0].cells[i].innerHTML;
if (str.search("<span></span>") != -1) {
for (var j = 0; j < rows.length; j++) {
rows[j].deleteCell(i);
}
}
}
</script>
</html>
Thanks
<span></span>then it has to correct thecolspanvalues for the second row and delete the column in the third row too?