2011-03-14 4 views
1

안녕하세요 두 행 등이 있습니다. 당신이 그들을 포기하고 아이디, 예를 들어 수, 나는 당신 만이 행을 복제 할복제 테이블 행

$("#" + tableId + "tbody") 
    .clone(true) 
    .insertAfter("#" + tableId + " tr:last"); 
$('#' + tableId + ' tbody:first>tr:last>td:last') 
    .empty() 
    .append("<input type=\"image\" id=\"imgDelete\" name=\"delete\" alt='' class=\"delete\" onclick='DeleteTableRow(this)' />"); 
+1

와우 (Wow) 이것을 약간 읽기 쉽도록 수정하십시오 ... – Matt

+0

서버 측 또는 클라이언트 측에서 행을 추가 하시겠습니까? 당신이해야 할 일은 클라이언트 측에서 jquery를 사용하는 것입니다. 서버 쪽면 asp.net MVC 도우미를 사용할 수 있습니다. – CallMeLaNN

답변

0

:

다음
<tr id="toClone_0"> 
    <td> 
    <%:Html.Label("Name")%> 
    <%:Html.TextBoxFor(model=>model.Name)%> 
    </td> 
</tr> 
<tr id="toClone_1"> 
    <td> 
    <%:Html.Label("Age")%> 
    <%:Html.TextBoxFor(model=>model.Age)%> 
    </td> 
</tr> 

jQuery를에 :

// select the elements whose id starts with 'toClone_' 
// false to avoid cloning of event handlers, true ohterwise 
var clonedRows = $("id^='toClone_'").clone(false); 

// insert the cloned rows after the last row 
$("#" + tableId + "tr:last").after(clonedRows); 
나는 이런 식으로 뭔가를 시도