Safari 在调用附加 jquery 方法时删除元素
我在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在隐藏字段周围放置一些
元素 - 没有它们就不是有效的 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.