Javascript ldtable>tbody:last').append(mytr); }); $(文档).on('focus','remove',函数(e){ e、 预防默认值(); $(this.parent().parent().remove(); }); }); 名称 年龄 地址 性别 我的物品 某个名字 30 我的地址 男性 烙印 量 大小 颜色 雅马哈 30 大的 黑色 删除客户 添加项 添加客户

Javascript ldtable>tbody:last').append(mytr); }); $(文档).on('focus','remove',函数(e){ e、 预防默认值(); $(this.parent().parent().remove(); }); }); 名称 年龄 地址 性别 我的物品 某个名字 30 我的地址 男性 烙印 量 大小 颜色 雅马哈 30 大的 黑色 删除客户 添加项 添加客户,javascript,jquery,html,this,Javascript,Jquery,Html,This,我为tr.customer和table.cart添加了,并分别在其中放置了按钮。它需要类和ID来简化复杂的任务 一小条 人事军官 桌子 运输署, th{ 边框:1px纯黑; } 名称 年龄 地址 性别 运货马车 某个名字 30 我的地址 男性 烙印 量 大小 颜色 雅马哈 30 大的 黑色 添加项 添加客户 $(“.addItem”)。在('click',函数(e){ $(this).closest('table')。find('item:last')。after('newitem'); }

我为
tr.customer
table.cart
添加了
,并分别在其中放置了按钮。它需要类和ID来简化复杂的任务

一小条

人事军官
桌子
运输署,
th{
边框:1px纯黑;
}
名称
年龄
地址
性别
运货马车
某个名字
30
我的地址
男性
烙印
量
大小
颜色
雅马哈
30
大的
黑色
添加项
添加客户
$(“.addItem”)。在('click',函数(e){
$(this).closest('table')。find('item:last')。after('newitem');
});
$(“.addCustomer”)。在('click',函数(e){
var newCustomer=$('.customer:last')。在('newCustomer')之后;
var newCart=$('.cart:first').clone(true,true).wrap('td');
newCart.find('tbody').html(“”.html('newitem');
$('.customer:last').append(newCart);
e、 预防默认值();
});
我为
tr.customer
table.cart
添加了
,并分别在其中放置了按钮。它需要类和ID来简化复杂的任务

一小条

人事军官
桌子
运输署,
th{
边框:1px纯黑;
}
名称
年龄
地址
性别
运货马车
某个名字
30
我的地址
男性
烙印
量
大小
颜色
雅马哈
30
大的
黑色
添加项
添加客户
$(“.addItem”)。在('click',函数(e){
$(this).closest('table')。find('item:last')。after('newitem');
});
$(“.addCustomer”)。在('click',函数(e){
var newCustomer=$('.customer:last')。在('newCustomer')之后;
var newCart=$('.cart:first').clone(true,true).wrap('td');
newCart.find('tbody').html(“”.html('newitem');
$('.customer:last').append(newCart);
e、 预防默认值();
});

单击“添加客户”时,应在包含某个名称的某行之后添加1行;?单击“添加自定义”时,应在包含某个名称的某行之后添加1行;?很好,很乐意帮忙,别忘了检查果岭✔.@zer00ne dude我如何选择子表中的每一行,以便我可以放置
删除按钮
每一行?内表表示购物车?查看
添加项
左侧的空间。它是一个
,但它是正常宽度的3倍。
有一个属性
colspan='3'
。制作
colspan=“2”
,然后添加一个新的
制作另一个问题。我会尝试用完整的代码回答它。我的意思是,添加一个删除功能,这样,如果我单击
删除按钮,只会删除它的行。很好,很高兴能提供帮助,别忘了检查绿色✔.@zer00ne dude我如何选择子表中的每一行,以便我可以放置
删除按钮
每一行?内表表示购物车?查看
添加项
左侧的空间。它是一个
,但它是正常宽度的3倍。
有一个属性
colspan='3'
。制作
colspan=“2”
,然后添加一个新的
制作另一个问题,我将尝试用完整的代码回答。我的意思是,添加一个删除功能,这样,如果我单击
删除按钮
,将仅删除其行。请单击以回答与此问题相关的其他问题。请单击以回答与此问题相关的其他问题。
<table>
    <thead>
        <tr>
           <th>Name</th>
           <th>Age</th>
           <th>Address</th>
           <th>Gender</th>
           <th>My Items</th>
        </tr>
    </thead>
    <tbody>
       <tr>
          <td>Some Name</td>
          <td>30</td>
          <td>My Address</td>
          <td>Male</td>
          <td>
             <table>
                <thead>
                  <tr>
                     <th>Brand</th>
                     <th>Quantity</th>
                     <th>Size</th>
                     <th>Color</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                     <td>Yamaha</td>
                     <td>30</td>
                     <td>Large</td>
                     <td>Black</td>
                  </tr>
                </tbody>
             </table>
             <button id="AddItem">Add Item</button>
          </td>
       </tr>
    </tbody>
</table>
<button id="AddCustomer">Add Customer</button>
$("#addItem").on('click', function(e) {
    $('tr:last').after("Added Row for Items.");
    e.preventDefault();
});
<br>

$("#addCustomer").on('click', function(e) {
    $('tr:last').after("Added Row for Customer.");
    e.preventDefault();
});
<table id="customerTable"></table>
<table id="productTable"></table>

$("#addCustomer").on('click', function(e) {
    $('#customerTable > tbody').append('<tr><td>New row</td></tr>');
    e.preventDefault();
});
// note, use class instead of using id if there will be multiple buttons.
$('.addCustomer').on('click', function() {
    // test if you get the correct table
    var table = $(this).closest('table');
    console.log(table);

    // if above not work try;
    var table = $(this).siblings('table');
    console.log(table);

    // if you successfully get the table you wanted,
    table.find('tbody').append('<tr><td>New customer row</tr>'); 
});
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="StackOverflow_Solve.jQueryAjax.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.12.0.min.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap.min.js" type="text/javascript"></script>
    <script>

        $(function () {
            //  $('#myModal').show();
            $('#AddItem').click(function(e) {
                e.preventDefault();
                var childtable = $(this).closest('tr').find('.childtable');
                console.log(childtable);
                var mytr = '<tr><td>Yamaha</td><td>1</td><td>Large</td><td>Black</td><td> <button id="remove" class="remove">remove Customer</button></td></tr>';
                $('#childtable > tbody:last').append(mytr);

            });
            $(document).on('focus', '.remove', function (e) {
                e.preventDefault();
                $(this).parent().parent().remove();
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
<table class="table table-bordered">
    <thead>
        <tr>
           <th>Name</th>
           <th>Age</th>
           <th>Address</th>
           <th>Gender</th>
           <th>My Items</th>
        </tr>
    </thead>
    <tbody>
       <tr>
          <td>Some Name</td>
          <td>30</td>
          <td>My Address</td>
          <td>Male</td>
          <td>
             <table id="childtable" class="childtable">
                <thead>
                  <tr>
                     <th>Brand</th>
                     <th>Quantity</th>
                     <th>Size</th>
                     <th>Color</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                     <td>Yamaha</td>
                     <td>30</td>
                     <td>Large</td>
                     <td>Black</td>
                     <td>
                         <button id="remove" class="remove">remove Customer</button>
                     </td>
                  </tr>
                </tbody>
             </table>
             <button id="AddItem">Add Item</button>
          </td>
       </tr>
    </tbody>
</table>
<button id="AddCustomer">Add Customer</button>

    </form>
</body>
</html>