[英]Appending a table column to a table with a span tag inside the td tag
I am trying to append a table column to a table row. 我试图将表列追加到表行。 I have the following code 我有以下代码
var row2 = $("<tr class='header' />").attr("id", "SiteRow");
row2.append($("<td id='FirstRowSite' <span> <img id='Plus' src='../images/Plus.png' > </span> />").text( UniqueSites[i].HubName));
$("#Overview").append(row2);
This appends the row just fine how ever the final result in html is displayed like this. 这样就很好地将行追加到html的最终结果中,像这样显示。
<td id="FirstRowSite" <span="">Acadieville</td>
As if it forgets my Span tag all together.. Perhaps I'm missing something small. 好像它一起忘记了我的Span标签。也许我缺少一些小东西。 Can anyone help me out I want the final result to look like this. 谁能帮帮我,我希望最终结果看起来像这样。
<td id="FirstRowSite"><span><img id="Plus" src="../images/Plus.png"></span>Acadieville</td>
var row2 = $("tr.header");
row2.append("<td id='FirstRowSite'><span><img id='Plus' src='../images/Plus.png' / ></span>" + UniqueSites[i].HubName + "</td>");
Simply like this : 就像这样:
var row2 = $("<tr class='header' />").attr("id", "SiteRow");
row2.append('<td id="FirstRowSite"><span><img id="Plus" src="../images/Plus.png"></span>'+ UniqueSites[i].HubName +'</td>');
$("#Overview").append(row2);
You can append html directly. 您可以直接附加html。
用这个
$("tr.header").append("<td id='FirstRowSite'><span><img id='Plus' src='../images/Plus.png' / ></span>" + UniqueSites[i].HubName + "</td>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.