脚本在 IE 中有效,在 FF 中无效?
function AddRow(){
var rowCount = $("td.RowClass").length;
var currentIndex = 0;
if (rowCount > 0)
{
currentIndex = rowCount--;
}
var markup = '<tr>';
markup += '<td class="RowClass" style="width:250px"><input type="text" id="TomId' + currentIndex + '" maxlength="78" size="70" /></td>';
markup += '<td><input style="width:245px" type="text" id="SerialNumber' + currentIndex + '" maxlength="30" size="25" />  ';
if (currentIndex >= 1)
{
markup += '<a id="removeTom' + currentIndex + '" href="#" onclick="RemoveTomControls(' + currentIndex + ')">Remove</a>';
}
markup += '</td></tr>';
$('#dataTable > tbody').append(markup);
}
这是我要附加的 html:
<div style="height:340px; overflow:auto;">
<table id="dataTable" style="margin:0px 1px 10px 5px; margin: width:800px;">
</table>
</div>
function AddRow(){
var rowCount = $("td.RowClass").length;
var currentIndex = 0;
if (rowCount > 0)
{
currentIndex = rowCount--;
}
var markup = '<tr>';
markup += '<td class="RowClass" style="width:250px"><input type="text" id="TomId' + currentIndex + '" maxlength="78" size="70" /></td>';
markup += '<td><input style="width:245px" type="text" id="SerialNumber' + currentIndex + '" maxlength="30" size="25" />  ';
if (currentIndex >= 1)
{
markup += '<a id="removeTom' + currentIndex + '" href="#" onclick="RemoveTomControls(' + currentIndex + ')">Remove</a>';
}
markup += '</td></tr>';
$('#dataTable > tbody').append(markup);
}
here's the the html I'm appending to:
<div style="height:340px; overflow:auto;">
<table id="dataTable" style="margin:0px 1px 10px 5px; margin: width:800px;">
</table>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与 IE 不同,Firefox 不会推断 tbody 元素,除非表中至少有一个 tr。
因此
$('#dataTable > tbody')
不匹配任何内容,并且您的附加不起作用。Firefox, unlike IE, won't infer a tbody element unless there is at least one tr in your table.
So
$('#dataTable > tbody')
matches nothing and your append has no effect.