jQuery .after() 在 IE 中不起作用
我正在尝试使用 .after()
将表行添加到表中,但它在任何 IE 中都不起作用,我不断收到此错误 "Object required"
和错误似乎来自我的 jQuery 库中的第 5151 行。
这是我的代码:
$('#view').live('click',function(){
var parent = $(this).parent();
parent.after("<tr><td>Test</td></tr>");
});
有什么想法吗?
I am trying to add a table row to a table using .after()
but it's not working in any IE, I keep getting this error "Object required"
and the error seems to be coming from line 5151 in my jQuery library.
Here is my code:
$('#view').live('click',function(){
var parent = $(this).parent();
parent.after("<tr><td>Test</td></tr>");
});
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能的原因是 HTML 代码在没有表格标记的情况下无效。
相反,将元素创建为单独的元素:
A likely reason is that the HTML code isn't valid without a table tag.
Create the elements as separate elements instead:
我肯定会首先验证你的 HTML;这种事情经常会失败,因为当事情无效时 IE 就不那么“慷慨”。
你知道什么是父母吗?它肯定是
tr
吗?I would definitely validate your HTML first; this kind of thing often fails beacuse IE is less "generous" when things aren't valid.
Do you know what parent is? is it definitely a
tr
?在 IE、FF 和 Chrome 中运行良好:演示。
Works fine for me in IE, FF and Chrome: demo.