i have
<table id="tbl_dtl">
<tr class = "table_print" id="sub_klp_row<?php echo $index; ?>">
<td id="sub_klp<?php echo $index; ?>" class = "style6" ><?php echo isset($sub_klp) ? $sub_klp : 'SUB KLP' ?> </td>
</tr>
<table>
because i need to use if condition i want to add <td>
code on below using javascript
<td id="sub_klp<?php echo $index; ?>" class = "style6" ><?php echo isset($sub_klp) ? $sub_klp : 'SUB KLP' ?> </td>
what i Already did so far
if (current_sub_klp.trim() != previous_sub_klp.trim()) {
//console.log(current_sub_klp);
var row = document.getElementsByClassName("sub_klp_row<?php echo $index; ?>");
var td = document.createElement("td");
td.name = "sub_klp<?php echo $index; ?>";
td.id = "sub_klp<?php echo $index; ?>";
row.appendChild(td);
}