简体   繁体   English

在剧院内插入tr和td

[英]Insert a tr and td inside a thead

I currently have a cshtml/javascript/jQuery webapp and I want to insert a <td> inside a <tr> inside an existing <thead> of a <table> . 我目前有一个cshtml / javascript / jQuery webapp,我想在<table>的现有<thead>内的<tr>内插入<td> <table> I don't know how can I insert <tr> inside an existing <thead> . 我不知道如何在现有的<thead>插入<tr> <thead> I know how to create one and fill it, but how can I insert new lines? 我知道如何创建并填充它,但是如何插入新行?

I want to insert: 我要插入:

<tr class="ligne" style="height: 0px; background-color: white;">
    <td style="border-bottom: black 1px solid; padding-bottom: 0px; height: 1px; padding-top: 0px;" colSpan="6"/>
</tr>

I want to insert it just under the selected line, below: 我想将其插入下面的所选行下面:

在此处输入图片说明

How can I achieve that? 我该如何实现?

If you want to add an element to a container, after the children of this container, use jQuery method append() . 如果要向容器中添加元素,请在该容器的子级之后使用jQuery方法append()

But if you want this element to be the first child of the container, use jQuery method prepend() . 但是,如果您希望此元素成为容器的第一个子元素,请使用jQuery方法prepend()

In your case, i would do : 在你的情况下,我会做:

$("#GrilleBilan .t-grid-header").prepend("<tr><td> ... </td></tr>")

try this : 尝试这个 :

<thead id='insert_tr'>
</thead>

This is your thead and you can insert tr and td both inside thead like this: 这是您的thead,您可以将tr和td都插入到thead中,如下所示:

var appendtr = "";
appendtr += "<tr><th></th></tr>";//And last append this variable inside thead:
 $("#insert_tr").append(appendtr);

you can also insert a multiple tr and td and th with tha help of for loop 您也可以在for循环的帮助下插入多个tr和td和th

for(var tr = 1; tr <= 5; tr++)
(
 appendtr += "<tr><th></th></tr>";
  $("#insert_tr").append(appendtr);
)

if you want to insert <tr><td></td></tr> after thead used the below code, 如果您要在广告使用以下代码后插入<tr><td></td></tr>

$('#GrilleBilan .t-grid-header').after('Your element to insert')

I am using table id (#GrilleBilan) because if you have more than one table, it did not replcated it other tables to. 我正在使用表ID(#GrilleBilan),因为如果您有多个表,它不会将其替换为其他表。

Sorry, I missed that 对不起,我错过了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM