InsertAfter在IE7中不起作用,但在FF中工作

时间:2013-03-06 06:24:54

标签: jquery html

我正在使用jquery 1.7.2.js

这是我在div之后插入的代码,

$("<div style="color: red">some text</div>").insertAfter('#main-Div');

这在我的FF中工作正常,但在IE7中没有。

我可以知道这背后的原因是什么?

3 个答案:

答案 0 :(得分:1)

您可以尝试.after()

$('#main-Div').after("some text"); // puts the text outside after #main-div

不确定您的座右铭是什么,您可以尝试.append()

$('#main-Div').append("some text"); // appends the text before any other elem 
                                   // in #main-div

答案 1 :(得分:0)

选中此this链接,必须已将元素插入到文档中。

您可能正在寻找

appendappendTo

答案 2 :(得分:0)

insertAfter仅在页面完全加载时才起作用。

使用它:

$("#main-div").appened('#some text');

$("some text").appendTo('#main-Div');
相关问题