Safari 在调用附加 jquery 方法时删除元素

发布于 2024-11-16 13:02:58 字数 1009 浏览 7 评论 0原文

我在使用 Safari 时遇到了一种非常奇怪的情况,而在其他浏览器(FF、IE、Chrome)中则没有。

我的 HTML 代码是这样的:

<table id="tblObjectChannel"></table>

我的脚本是这样的:

var item = '<tr style="border-bottom:solid 1px #666;" id="xxxccc"><input type="hidden" id="hfObjectID0" value="2323" /></tr>';            

$('#tblObjectChannel').append(item);

在 Safari 以外的浏览器中,它将像这样返回:

<tbody><tr style="border-bottom: 1px solid rgb(102, 102, 102);" id="xxxccc"><input id="hfObjectID0" value="2323" type="hidden"></tr></tbody>

但在 Safari 中,它会像这样返回:

<tbody><tr style="border-bottom: 1px solid rgb(102, 102, 102);" id="xxxccc"></tr></tbody>

所以,隐藏的元素被丢弃了,我不知道在哪里。我在这里缺少 .append() 方法的隐藏功能吗?

您可以在这里亲自见证这一点:http://jsfiddle.net/mrMXS/ 请尝试使用 FF 链接,然后使用 Safari 链接。任何线索将不胜感激。

谢谢

I encounter a very strange situation with safari while not with other browsers (FF, IE, Chrome).

My HTML code is something like this:

<table id="tblObjectChannel"></table>

And my script is something like this:

var item = '<tr style="border-bottom:solid 1px #666;" id="xxxccc"><input type="hidden" id="hfObjectID0" value="2323" /></tr>';            

$('#tblObjectChannel').append(item);

In browsers other than Safari it will return like this:

<tbody><tr style="border-bottom: 1px solid rgb(102, 102, 102);" id="xxxccc"><input id="hfObjectID0" value="2323" type="hidden"></tr></tbody>

But in Safari it returns like this:

<tbody><tr style="border-bottom: 1px solid rgb(102, 102, 102);" id="xxxccc"></tr></tbody>

So, the hidden element is thrown away I don't know where. Am I missing a hidden feature of .append() method here?

You can witness this yourself here: http://jsfiddle.net/mrMXS/
please try that link with FF and then with Safari. Any clue would be appreciated.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

若能看破又如何 2024-11-23 13:02:58

尝试在隐藏字段周围放置一些 元素 - 没有它们就不是有效的 HTML。

请参阅 http://jsfiddle.net/alnitak/mdUeu/ - 在 MacOS X 上的 Safari 上进行测试按预期工作。

Try putting some <td> elements around your hidden field - it's not valid HTML without them.

See http://jsfiddle.net/alnitak/mdUeu/ - tested on Safari on MacOS X and it works as expected.

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