ช่วยแปลง html เป็น javascrip ให้หน่อยครับ

html code
--------------------------------
           <tbody>
                            <tr>
    <td>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="itemRow custom-control-input" id="itemRow_1">
<label class="custom-control-label" for="itemRow_1"></label>
</div>
</td>
//------------ 1
                                <td>
<select name="tcodedesc[]" id="tcodedesc_1" class="form-control selectpicker show-tick" data-live-search="true"  placeholder="Type to search sparepart item..."  required data-width="100%">
<?php
require('inc/getItemcodeNames.php');
  ?>
</select>
</td>
//--------------- end 1
                                <td><input type="text" required class="form-control" id="tqty_1" name="tqty[]" autocomplete="off"  placeholder="0.00"></td>
                                <td><input type="text" required class="form-control" id="tperunit_1" name="tperunit[]" autocomplete="off"  placeholder="0.00"></td>
                                <td><input type="text" required class="form-control" id="tamt_1" name="tamt[]" placeholder="0.00"></td>
                                <td><input type="text" required class="form-control" id="tvat_1"  name="tvat[]" placeholder="0.00" ></td>
                                <td><input type="text" class="form-control" id="tdiscount_1" name="tdiscount[]" placeholder="0.00"></td>
                                <td><input type="text" class="form-control" id="tremark_1" name="tremark[]"></td>
//------2
<td><input type="button" value="X" onclick="removeRow(this,'invoiceItem');" class="btn btn-danger btn-xs"/></td>
// end 2
                            </tr>
                        </tbody>
--------------------------------------------------------------------------------------------------------------------------
เมื่อ คลิก add ให้ทำงานใน javascript เพื่อข้นบรรทัดใหม่ บรรทัดที่ 1 และ 2 ที่ mark ไว้ไม่ทำงานครับ
ผมคิดว่าผมใส่  ' หรือ " ไม่ถูก รบกวนด้วยครับ
------------------------------------------------------------------------------------------------------------------------
<script>
var count = $(".itemRow").length;
$(document).on('click', '#addRows', function() {
count++;
var htmlRows = '';
htmlRows += '<tr>';
htmlRows += '<td><div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input itemRow" id="itemRow_'+count+'"> <label class="custom-control-label" for="itemRow_'+count+'"></label> </div></td>';          

//--- LINE 1 THIS LINE NOT WORK WHEN CLICK ADD -----------//
htmlRows += '<td>
<select name="tcodedesc[]" id="tcodedesc_1" class="form-control selectpicker show-tick" data-live-search="true"  placeholder="Type to search sparepart item..."  required data-width="100%">
<?php
require('inc/getItemcodeNames.php');
  ?>
</select>
</td>';
//-- LINE 1 THIS LINE NOT WORK WHEN CLICK ADD END--------- -->

htmlRows += '<td><input type="number" name="tqty[]" id="tqty_'+count+'" class="form-control " autocomplete="off"></td>';  
htmlRows += '<td><input type="number" name="tperunit[]" id="tperunit_'+count+'" class="form-control " autocomplete="off"></td>';
htmlRows += '<td><input type="number" name="tamt[]" id="tamt_'+count+'" class="form-control total" autocomplete="off"></td>';          
htmlRows += '<td><input type="text" name="tdiscount[]" id="tdiscount_'+count+'" class="form-control" autocomplete="off"></td>';
htmlRows += '<td><input type="text" name="tvat[]" id="tvat_'+count+'" class="form-control" autocomplete="off" placeholder="7"></td>';
htmlRows += '<td><input type="number" name="tremark[]" id="tremark_'+count+'" class="form-control total" autocomplete="off"></td>';    

//---- LINE 2  THIS LINE NOT WORK WHEN CLICK ADD-----------//
htmlRows +='<td><input type="button" value="X" onclick=\'removeRow("this","invoiceItem")\;" class="btn btn-danger btn-xs"/></td>';
//---- LINE 2  THIS LINE NOT WORK WHEN CLICK ADD END-----------//

htmlRows += '</tr>';
// console.log(response);
$('#invoiceItem').append(htmlRows);
});
</script>
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่