脚本在 IE 中有效,在 FF 中无效?

发布于 2024-10-05 08:57:11 字数 987 浏览 0 评论 0原文

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" />&nbsp&nbsp';

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人生百味 2024-10-12 08:57:11

与 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文