I have a table containing rowspan (Merged Rows), I need to split that merged rows into individuals and put the rowspan value in last td.
NOTE: In my cod
Try this:
$('table td').each(function() {
var _parent_tr = $(this).parent();
var rowspan = $(this).attr('rowspan');
var rowspanVal = $(this).attr('rowspan');
$(this).removeAttr('rowspan');
if (rowspan && rowspan>1) {
for(var i=1;i<=rowspan;i++){
_parent_tr.append("<td>"+rowspanVal+"</td>");
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border="1" cellpadding="2" cellspacing="0" id="0" style="border-collapse: collapse;" class="dataTable">
<tbody>
<tr style="height:15.0pt;">
<td><input type="checkbox" id="row_0" class="dt-checkboxes_1" value=""></td>
<td class="td_0_2" rowspan="2">#<input type="checkbox" id="td_0" class="hrchy-dt-checkboxes" value=""></td>
<td class="td_0_2"> </td>
<td class="td_0_2"> </td>
<td class="td_0_3">(Invested Assets)</td>
<td class="td_0_3">(Admitted Assets)</td>
<td class="td_0_4">Pasivos (Liabilities)</td>
<td class="td_0_4">Pasivos (Liabilities)</td>
<td class="td_0_4">Pasivos (Liabilities)</td>
<td class="td_0_4">Pasivos (Liabilities)</td>
<td class="td_0_4">Pasivos (Liabilities)</td>
<td class="td_0_4">Pasivos (Liabilities)</td>
</tr>
<tr style="height:15.0pt;">
<td><input type="checkbox" id="row_1" class="dt-checkboxes_1" value=""></td>
<td class="td_0_3">(NAIC Code)<input type="checkbox" id="td_1" class="hrchy-dt-checkboxes" value=""></td>
<td class="td_0_3">( Domestics Insurers)</td>
<td> </td>
<td> </td>
<td class="td_0_3">(Aggregate Reserve for Life Contracts)</td>
<td class="td_0_3">(Reserve for Life Contract Claims)</td>
<td class="td_0_6">(Aggregate Reserve for Accident and Health Contract Claims)</td>
<td class="td_0_6">(Reserve for Accident and Health Contracts Claims)</td>
<td class="td_0_3">(Other Liabilities)**</td>
<td class="td_0_3">(Total Liabilities)</td>
</tr>
</tbody>
</table>