When the user presses the text "Add", then I'd like to create a new row with an input tag. I think I've got most of it working.
<!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(OnLo开发者_高级运维ad);
</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>
Like this:
newRow.children('td:last').empty().append('<input>Whatever</input>');
精彩评论