Javascript 在追加时清除所有输入文本框vale

Javascript 在追加时清除所有输入文本框vale,javascript,Javascript,我想要的是,当我单击“添加更多”时,使用空白值附加所有文本框“添加更多”功能正常工作,但在附加输入框“附加更多值”时,我希望清除文本框值 <table> <tbody> <tr class="topdivdata"> <td> <input type="text" value="First Name"></td> <td> <input type="text" value=

我想要的是,当我单击“添加更多”时,使用空白值附加所有文本框“添加更多”功能正常工作,但在附加输入框“附加更多值”时,我希望清除文本框值

 <table>
    <tbody>
    <tr class="topdivdata">
    <td> <input type="text" value="First Name"></td>
    <td> <input type="text" value="Last Name"></td>
    <td> <input type="text" value="Mobile Number"></td>
    </tr>
    <tr role="row" class="odd">
    <td>
    <span class="btn btn-xs cic" id="addnewunit">
    <i class="icon-plus"></i>+ Add More</span>
    </td>   
    </tr>
    </tbody>
    <tbody id="addmoreunit"></tbody>
    </table>

    <script src="https://code.jquery.com/jquery-1.12.3.js"></script>

    <script>
    unitcount=1;
     $('#addnewunit').click(function()
                {
                 var topdiv = $('.topdivdata').html();  
                 var refresdiv=topdiv;
            $('#addmoreunit').append('<tr>.'+refresdiv+'.<td class="removes1"><span class="btn btn-xs"><i class="icon-plus"></i>- Remove</span></td></tr>');    
    unitcount++;
        var value = $('.target').val();
                    $('.list').val(value);
                    $('.removes1').click(function()
                        {
                            $(this).parent().remove();
                        });
    });

    </script>

+添加更多
单位计数=1;
$('#addnewunit')。单击(函数()
{
var topdiv=$('.topdivdata').html();
var refresdiv=topdiv;
$('#addmoreunit')。追加('.+refresdiv+'.-Remove');
unitcount++;
var值=$('.target').val();
$('.list').val(值);
$('.removes1')。单击(函数()
{
$(this.parent().remove();
});
});
我想在单击“添加更多”“附加所有空白值文本框”时添加更多正常工作的功能,但在附加时输入框将值翻转,但我想清除文本框值
+添加更多
单位计数=1;
$('#addnewunit')。单击(函数()
{
var topdiv=$('.topdivdata').html();
var refresdiv=topdiv;
$('#addmoreunit')。追加('.+refresdiv+'.-Remove');
unitcount++;
var值=$('.target').val();
$('.list').val(值);
$('.removes1')。单击(函数()
{
$(this.parent().remove();
});
});

不理解您的问题,但您可以这样做

<table>
 <tbody>
    <tr class="topdivdata">
        <td>
            <input type="text" value="First Name">
        </td>
        <td>
            <input type="text" value="Last Name">
        </td>
        <td>
            <input type="text" value="Mobile Number">
        </td>
    </tr>
    <tr role="row" class="odd">
        <td>
            <span class="btn btn-xs cic" id="addnewunit" style="cursor:Pointer;">
                <i class="icon-plus"></i>+ Add More
            </span>
        </td>
    </tr>
</tbody>
<tbody id="addmoreunit"></tbody>
</table>

+添加更多
剧本是这样的

 var unitcount = 1;
$('#addnewunit').click(function () {

    //Here i cloned your topDiv, so that i can add new inputs.
    var CloneTopDiv = $('.topdivdata').clone(true);
    CloneTopDiv.find(':input').attr('value', '');
    CloneTopDiv.attr('class', 'txtInput')
    CloneTopDiv = CloneTopDiv.html();
    var refresdiv = CloneTopDiv;
    $('#addmoreunit').append('<tr>.' + refresdiv + '.<td class="removes1"><span class="btn btn-xs" style="cursor:Pointer;"><i class="icon-plus"></i>- Remove</span></td></tr>');
    unitcount++;
    var value = $('.target').val();
    $('.list').val(value);

    //Code for Remove added row
    $('.removes1').click(function () {
        $(this).parent().remove();
    });

    //Clearing Code
    $('.txtInput').val('')

});
var unitcount=1;
$('#addnewunit')。单击(函数(){
//在这里,我克隆了您的topDiv,以便添加新的输入。
var CloneTopDiv=$('.topdivdata').clone(true);
CloneTopDiv.find(':input').attr('value','');
CloneTopDiv.attr('class','txtInput')
CloneTopDiv=CloneTopDiv.html();
var refresdiv=CloneTopDiv;
$('#addmoreunit')。追加('.+refresdiv+'.-Remove');
unitcount++;
var值=$('.target').val();
$('.list').val(值);
//删除添加行的代码
$('.removes1')。单击(函数(){
$(this.parent().remove();
});
//清算代码
$('.txtInput').val('')
});

请参见

什么解决方案?你能更清楚地解释一下吗?@RayonDabre答案很好。在第一个tr中,所有输入值都不应该是清晰的,只有新的附加输入框值应该是空白的