我有一张桌子:
<table id="fTable">
<tbody>
<tr id="fRow">
</tr>
</tbody>
</table>
我有一个有30列的网格,如何做所有这些列来分隔<td>
并想要设置<td>
id,width,text或innerHtml属性。
var row = $('#fRow');
for(var i= 2; i < Columns.length ; i++)
{
}
正如我想的那样(以及评论)......你是新手使用jquery ...所以使用jquery非常简单... append / appendTo就是你要找的......
如果你想为TD添加多个表,那么使用ID属性是没用的。因为W3C说ID在页面上是唯一的...更好地使用class属性...
<table class="floatTable">
<tbody>
<tr class="footerRow">
</tr>
</tbody>
</table>
// Select all TRs in the floatTable having the class footerRaw
$('.floatTable tr.footerRaw').each(function(key, el)) {
// here you could define anything whatever you want
var tdContent = 'Lorem ipsum dolor';
// For example add five TDs to your table
for ( var i = 0; i < 5; i++ ) {
// if it works ;-)
// ...it should add following:
// <td>Lorem ipsum dolor #1</td>
// <td>Lorem ipsum dolor #2</td>
// ...and so on...
$(this).append('<td>' + tdContent + ' #' + i + '</td>');
}
});
这是一个正在运行的例子...... http://jsfiddle.net/2am6wcm8/