Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Jquery将行添加到表中,但不要';我不需要它的价值_Jquery - Fatal编程技术网

使用Jquery将行添加到表中,但不要';我不需要它的价值

使用Jquery将行添加到表中,但不要';我不需要它的价值,jquery,Jquery,可能重复: 我正在尝试向表中添加行。我发现我们可以使用克隆。我的表格中有两个文本框,分别位于两个不同的tr中。克隆最后一行也会复制我不想要的文本框中的值?有什么想法吗 我的代码 $("#table-1 tr:last").clone(); 可能是这样的 $("#table-1 tr:last").clone().find('input[type=text]').val(''); 如果要添加包含输入的行,而不是包含值的行,可以执行与现有操作类似的操作,只需清除值: var row = $(

可能重复:

我正在尝试向表中添加行。我发现我们可以使用克隆。我的表格中有两个文本框,分别位于两个不同的tr中。克隆最后一行也会复制我不想要的文本框中的值?有什么想法吗

我的代码

$("#table-1 tr:last").clone();

可能是这样的

 $("#table-1 tr:last").clone().find('input[type=text]').val('');

如果要添加包含输入的行,而不是包含值的行,可以执行与现有操作类似的操作,只需清除值:

var row = $("#table-1 tr:last").clone();
row.find( 'input' ).each( function(){
    $( this ).val( '' )
});
row.appendTo( "#table-1" )

克隆后只需清除输入字段:

var row = $("#table-1 tr:last").clone().find(':input').val('').end();

// then add the row at the end of the table
$("#table-1").append(row);

请不要在不同的帐户下重复相同的问题。投票结束,这是一个重复的:我假设,我的答案,你的行有输入。。如果您可以发布该行的html,我们可以提供更好的帮助。