Is there any way I can add a column based on another column's attribute? Something like this: If a td has attribute colspan="2", then add one new before it. Thank you.
<table>
<tr>
<td>aaa</td>
<td colspan="2">bbb</td>
<td>ccc</td>
<td>ddd</td>
<td colspan="2">eee</td>
</tr>
</table>
The result table should be:
<table>
<tr>
<td>aaa</td>
<td> just added based on the right below column tag</td>
<td colspan="2">bbb</td>
<td>ccc</td>
<td>ddd</td>
<td> just added based on the right below column tag</td>
<td colspan="2">eee</td>
</tr>
</table>
Based on the help from Reigel and Rob, here is the complete example:
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('td[colspan=2]').before('<td> just added based on the right below column tag</td>') ;
});
</script>
<body>
<table border="1">
<tr>
<td>aaa</td>
<td colspan="2">bbb</td>
<td>ccc</td>
<td>ddd</td>
<td colspan="2">eee</td>
</tr>
</table>
</body>
</html>