我们可以在<tr> </ tr>之后使用嵌套表吗?

use*_*856 5 javascript php jquery html5 html-table

我在表列表中显示数据库中的记录。另外,我在每行中都有一个跟踪按钮,如果任何用户单击跟踪按钮,则会为特定用户打开一个包含详细信息的弹出窗口。

或任何其他想法来解决这个问题?

我试图用这样的东西

<table>
<thead><tr><th></th></tr></thead>
<tbody>
<tr><td></td></tr>

<div style="display:none">
<table>
<thead><tr><th></th></tr></thead>
<tbody>
<tr><td></td></tr>
</tbody>
</table>
</div>

</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

完整代码

        <!DOCTYPE html>
            <html>
            <head>
                <title></title>
            </head>
            <body>

                <table border="1">
                    <thead>
                        <tr>>
                        <th>Name</th>
                        <th>Products</th>
                        <th>Qty</th>
                        <th>Order Id</th>
                        <th>Mobile </th>
                        <th>Shipping address</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php  $n=1;
                         foreach ($cust_personal as $row)  
                         { $encryption_id=base64_encode($this->encryption->encrypt($row->o_id));//encrpt the id 
                            ?>
                            <tbody>
                            <tr>
                              <td><?php echo $n;?></td>
                              <td><?php echo $row->c_firstname;?>&nbsp; <?php echo $row->c_lastname;?></td>
                              <td><?php echo $row->o_product_brandname;?></td>    
                              <td><?php echo $row->o_product_qty;?></td>  
                              <td><?php echo $row->o_order_no;?></td>
                              <td><?php echo $row->c_mobileno;?></td>  
                              <td><?php echo $row->c_s_address;?></td>
        <td> <a  href="javascript:void(0)" class="table_icon pending" onclick="approve(this)" data-id="<?=$row->o_id;?>"> <span>Pending</span></a>
        <a href="<?php echo site_url('Customer_control/get_customer_view?key='.$encryption_id)?>" class="table_icon view">View</a> 
        <a href="javascript:void(0)" class="table_icon archive" onclick="followup(this)" data-id="<?=$row->o_id;?>">Followup</a>
                        </tr>

     <div id="popup-<?=$row->o_id;?>" style="display: none;" class="class="view_popup_profile">
      <div class="profile_content">
    <div class="profile_header clearfix">
                <table border="1">
                    <thead><th>sub</th></thead>
                    <tbody><tr><td>maths</td></tr></tbody>
                </table>
</div></div>
                </div>
                       <?php } $n++; ?> 
                    </tbody>
                </table>
            <script type="text/javascript">
                function followup(obj) 
            {
                var id = $(obj).data('id');
                //console.log(id);
                $("#popup-"+id).show();  
            }
            </script>
            </body>
            </html>
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出。 在此处输入图片说明

为什么需要嵌套表,因为当我添加以下代码并单击“跟进”按钮时,我会在全屏模式下看到弹出窗口。

</tr>
 <div id="popup-<?=$row->o_id;?>" style="display: none;">
    <!--more details here-->
      </div>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

如果我在弹出窗口中添加了一个表格以显示以下列表,则该表格不起作用。

    </tr>
     <div id="popup-<?=$row->o_id;?>" style="display: none;">
            <table border="1">
                    <thead><th>sub</th></thead>
                    <tbody><tr><td>maths</td></tr></tbody>
                </table>
</div>
    </tbody>
    </table>
Run Code Online (Sandbox Code Playgroud)

的CSS

        .view_popup_profile {
    position: fixed; /* Stay in place */
    z-index: 9; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    -webkit-animation-name: fadeIn; /* Fade in the background */
    -webkit-animation-duration: 0.4s;
    animation-name: fadeIn;
    animation-duration: 0.4s;
}
/* Modal Content */
.profile_content {
    position: fixed;
    top: 25%;
    background-color: #fefefe;
    width: 100%;
    -webkit-animation-name: slideIn;
    -webkit-animation-duration: 0.5s;
    animation-name: slideIn;
    animation-duration: 0.5s;
    max-width: 922px;
    margin: auto;
    left: 0;
    right: 0;
    box-shadow: 0 0 15px rgba(0,0,0,.3);
}
/* The Close Button */

.profile_header {
    padding: 1px 20px;
    background-color: #fafafc;
    color: white;
    /* min-height: 58px; */
    border-bottom: 1px solid #f7f7f7;
    display: block;
    width: 100%;
}
.profile_header:after {
    content: '';
    width: 0;
    height: 0;
    border-left: 17px solid transparent;
    border-right: 17px solid transparent;
    border-top: 16px solid #f7f7f7;
    position: absolute;
}
.profile_body {
    padding: 35px 50px;
}
.profile_footer {
    padding: 0;
    background-color: #fdfdfe;
    color: #858585;
}
p{color: #000;}
    /* Add Animation */
    @-webkit-keyframes slideIn {
 from {
 top: -500px;
 opacity: 0
}
 to {
 top:25%;
 opacity: 1
}
}
 @keyframes slideIn {
 from {
 top: -500px;
 opacity: 0
}
 to {
 top:25%;
 opacity: 1
}
}
 @-webkit-keyframes fadeIn {
 from {
 opacity: 0
}
 to {
 opacity: 1
}
}
 @keyframes fadeIn {
 from {
 opacity: 0
}
 to {
 opacity: 1
}
}
Run Code Online (Sandbox Code Playgroud)

git*_*oge 0

是的,您绝对可以在表中添加表,但请记住将它们添加到表单元格中,<td></td>
下面是参考链接,不要害怕尝试!
ref : https://www.yourhtmlsource.com/tables/nestingtables.html
(注:如果您担心在单元格中创建额外的空格,您可以在 css 中修改单元格或嵌套表格的样式,例如调整边距或填充。
插件:
您可以尝试使用 jquery 从单击的链接中获取并从链接中data删除onclick=followup(this)

将其添加到您的脚本中并尝试一下:

$(".archive").on('click',function(){
        var id = $(this).data('id');
        $("#popup-"+id).show();
})
Run Code Online (Sandbox Code Playgroud)