我有
<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>
因为我需要使用if条件我想在下面使用javascript添加<td>
代码
<td id="sub_klp<?php echo $index; ?>" class = "style6" ><?php echo isset($sub_klp) ? $sub_klp : 'SUB KLP' ?> </td>
到目前为止我已经做了什么
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);
}