Javascript 将所选行传输到另一个表

Javascript 将所选行传输到另一个表,javascript,Javascript,我从数据库中获取数据,并将其显示在带有复选框的表中。我要做的是,所选行应移到第二个表中,我不希望第二个表中出现复选框列。代码如下: <table class="table"> <tr> <th></th> <th>Business Identifier</th> <th>Site Name</th> <th>City

我从数据库中获取数据,并将其显示在带有复选框的表中。我要做的是,所选行应移到第二个表中,我不希望第二个表中出现复选框列。代码如下:

 <table class="table">
    <tr>
        <th></th>
        <th>Business Identifier</th>
        <th>Site Name</th>
        <th>City</th>
        <th>Postcode</th>
    </tr>
    @if (Model.UserAccountSummary != null && Model.UserAccountSummary.Any())
    {
        foreach (var item in Model.UserAccountSummary)
        {
            <tr>
                <td>

                   <input name="Id" type="checkbox" value="@item.business_customer_identifier" class="chkclass"></td>

                <td>@Html.DisplayFor(modelItem => item.business_customer_identifier)</td>
                <td>@Html.DisplayFor(modelItem => item.customer_name)</td>
                <td>@Html.DisplayFor(modelItem => item.postal_town)</td>
                <td>@Html.DisplayFor(modelItem => item.postcode)</td>
            </tr>
        }
    }

</table>

业务标识符
站点名称
城市
邮政编码
@if(Model.UserAccountSummary!=null&&Model.UserAccountSummary.Any())
{
foreach(Model.UserAccountSummary中的var项)
{
@DisplayFor(modelItem=>item.business\u customer\u标识符)
@DisplayFor(modelItem=>item.customer\u name)
@DisplayFor(modelItem=>item.postal\u town)
@DisplayFor(modeleItem=>item.postcode)
}
}
以下是JS代码:

$().ready(function () {
        $(".table").on("click", ".chkclass", function () {
            if ($(this).is(":checked")) {
                var trItem = $(this).closest("tr").clone();
                trItem.add("<tr>").append("</tr>");

                $("#targetTable").append(trItem);
            }
        });
    });
$().ready(函数(){
$(“.table”)。在(“单击”,“.chkclass”,函数(){
如果($(this).is(“:checked”)){
var trItem=$(this.close(“tr”).clone();
添加(“”)。追加(“”);
$(“#targetTable”)。追加(trItem);
}
});
});
试试这个:

$(document).ready(function(){
    $().ready(function () {
        $(".table").on("click", ".chkclass", function () {
            if ($(this).is(":checked")) {
                var trItem = $(this).closest("tr").clone();
             trItem.find("input").remove();
                trItem.add("<tr>").append("</tr>");

                $("#targetTable").append(trItem);
            }
        });
    });
});
$(文档).ready(函数(){
$().ready(函数(){
$(“.table”)。在(“单击”,“.chkclass”,函数(){
如果($(this).is(“:checked”)){
var trItem=$(this.close(“tr”).clone();
trItem.find(“输入”).remove();
添加(“”)。追加(“”);
$(“#targetTable”)。追加(trItem);
}
});
});
});

以下是用于将记录从一个表复制到另一个表的JS代码,而无需在目标表中选择checbox:

  $(document).ready(function () {
        $().ready(function () {
            $(".table").on("click", ".chkclass", function () {
                if ($(this).is(":checked")) {
                    var trItem = $(this).closest("tr").clone();
                    trItem.find("input").remove();
                    trItem.add("<tr>").append("</tr>");

                    $("#targetTable").append(trItem);
                }
            });
        });
    });
$(文档).ready(函数(){
$().ready(函数(){
$(“.table”)。在(“单击”,“.chkclass”,函数(){
如果($(this).is(“:checked”)){
var trItem=$(this.close(“tr”).clone();
trItem.find(“输入”).remove();
添加(“”)。追加(“”);
$(“#targetTable”)。追加(trItem);
}
});
});
});

移动或复制。。现在您正在使用克隆方法将其复制到第二个表中。我正在尝试复制记录,当前它也在复制复选框选择。如何省略CheckboxJust put:trItem.find(“input”).remove();ater clone method..谢谢你的代码,但目前我不想从源表中删除任何记录,我只想在第二个表上复制记录,不选择复选框谢谢你的回答
  $(document).ready(function () {
        $().ready(function () {
            $(".table").on("click", ".chkclass", function () {
                if ($(this).is(":checked")) {
                    var trItem = $(this).closest("tr").clone();
                    trItem.find("input").remove();
                    trItem.add("<tr>").append("</tr>");

                    $("#targetTable").append(trItem);
                }
            });
        });
    });