开发者

jquery Inserted a new row

开发者 https://www.devze.com 2022-12-21 07:39 出处:网络
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.

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>');
0

精彩评论

暂无评论...
验证码 换一张
取 消