js
[jQuery] 동적으로 자식창에서 부모창으로 tr td 추가/ 삭제
natrue
2021. 3. 11. 15:32
728x90
1. 추가하기 .innerHTML
부모창 html 부분
<table>
<thead>
<tr>
<th>구분</th>
<th>위치</th>
<th>장치명</th>
</tr>
</thead>
<tbody id="senInsertList">
</tbody>
</table>
자식창 js 부분
var senList = '';
senList += '<tr class="senListTr'+num+'">';
senList += '<td class="typeText'+num+'">'+ sensorTypeText +'</td>';
senList += '<td class="senCodeDetlNm'+num+'">'+ codeDetlNm +'</td>';
senList += '<td class="resultInput'+num+'">'+ resultInput +'</td>';
senList += '</tr>';
parent.document.getElementById("senInsertList").innerHTML += senList;
2. 삭제하기 .remove();
parent.document.getElementsByClassName("sensorListTr"+num).item(0).remove();