2010-02-24 2 views
0

사용자가 텍스트 "추가"를 누르면 입력 태그가있는 새 행을 만들고 싶습니다. 나는 그것의 대부분이 일하고 있다고 생각합니다. 이처럼jquery 새 행을 삽입했습니다.

<!DOCTYPE HTML> 
<html> 
<head> 
<script src="http://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
function OnLoad() { 
    $('.insert').live('click', function() { 
     var currentRow = $(this).parents("tr:first"); 
     var newRow = currentRow.clone(true); 
     // Help need here: change the 3rd table data into an input control 
     currentRow.after(newRow); 
    }); 
} 
google.load("jquery", "1"); 
google.setOnLoadCallback(OnLoad); 
</script> 
</head> 
<body> 
<form> 
<table border="1"> 
<tr> 
<td class="insert">Add</td> 
<td class="delete">Erase</td> 
<td>Sample data goes here</td> 
</tr> 
</table> 
</form> 
</body> 
</html> 

답변

3

:

newRow.children('td:last').empty().append('<input>Whatever</input>'); 
+0

감사합니다! 이것은 나를 시작하게했다. –

관련 문제