I would like to hide the complete column including the heading if data is empty or null. I tried to do this with jquery, but iam not able to accomplish what iam trying. Basically iam getting some records in PHP. Some columns doesnt have data, so i dont need to show the empty data or data which is NULL. Can anyone guide me on whats the mistake iam making.
<html>
<head>
<title>Hide</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
</head>
<body>
<table border="1" width="100%" id="mytable">
<thead>
<tr>
<th>Head1</th>
<th>Head2</th>
<th>Head3</th>
</thead>
</tr>
<tr>
<td>aa</td>
<td></td>
<td>cc</td>
</tr>
<tr>
<td>aa</td>
<td></td>
<td>cc</td>
</tr>
<tr>
<td>aa</td>
<td></td>
<td>cc</td>
</tr>
</table>
</body>
</html>
<script type='text/javascript'>
$(window).load(function(){
$('#mytable > tbody > tr td:empty').parent().hide()
if($td.text() == ''){
$(this).hide();
}
});
});
</script>
$tduntil after you assign a value to it.