使用Jquery将行添加到表中,但不需要它的值 [英] Add row to a table with Jquery,but don't need its value
本文介绍了使用Jquery将行添加到表中,但不需要它的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
How can I clone a row in a table without cloning the values of the input elements inside it?
我正在尝试向表中添加一行.我发现我们可以使用clone.我的表在两个不同的tr中有两个文本框.克隆最后一行也复制了我不希望的文本框中的值?任何想法
i am trying to add a row to a table.i found that we can use clone . my table has two text boxes in it in two different tr's .cloning the last row is also duplicating the values in my textbox's which i don't want ?Any ideas ???
我的代码
$("#table-1 tr:last").clone();
推荐答案
如果要添加输入而不是值的行,则可以执行类似的操作,并清除值:>
If you want to add a row with the inputs, but not the values, you could do something like what you have, and just clear the values:
var row = $("#table-1 tr:last").clone();
row.find( 'input' ).each( function(){
$( this ).val( '' )
});
row.appendTo( "#table-1" )
这篇关于使用Jquery将行添加到表中,但不需要它的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文