2014-07-23 4 views
3

많은 열이있는 테이블이 있습니다.부분적으로 행을 복제하는 방법

현재 코드에서는 마지막 행의 모든 ​​항목을 복제합니다.

$("#tTable tbody tr:last").clone(true).insertBefore($("#tTable tbody tr:last")).show(); 
요소를 제외한 모든 복사 할 수 있도록

어떻게이 코드를 수정할 수 있습니다 lList, C-SPAN과 아이를? td of first을 찾을

<table id="tTable"> 
    <tbody> 
    <tr> 
    <td> 
       <select id="lList" class="listClass"> 

       <option value="0">(select here)</option> 
       <span class="cSpan"><input title="custom" class="custom-combobox-input ui-autocomplete-input" autocomplete="off"> 
       <a class="comboboxButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only custom-combobox-toggle" tabindex="-1" role="button"><span class="ui-button-text"></span></a> 
       <div id="labelDiv"><label id="displayComboBoxText"></label>/div> 
       <input id="ID" name="ID" type="hidden" value=""> 

    </td> 
    </tr> 
    </tbody> 
</table> 

답변

2

사용 찾기 선택기 다음은

var row=$("#tTable tbody tr:last").clone(true).find("td:first").remove().end(); 
+0

@AustinMullins 지금 난 그냥 최종 연료 소모량을 – Balachandran

0

이 하나가 나를 위해 일한 제거 : Fiddle

var tr = $("#tTable tbody tr:last"); 
var trCopy = tr.clone(true); 

trCopy.find("td:first").remove(); 

trCopy.insertBefore(tr).show(); 

.remove() 기능을 (적어도 jQuery를 2.1.0에서) 선택한 요소를 부작용으로 제거하고 선택을 반환합니다.

그것을 제거하지 않고 선택한 칼럼의 내용을 비우려면, html("")를 사용

trCopy.find("td:first").html(""); 
+0

감사를 사용하여 확인이 완전히 열을 제거합니다. 난 칼럼을 지키고 그 아이들을 제거하고 싶다. – learning

관련 문제