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();