我正在尝试使用 jQuery 将 iframe
插入到 div
中,下面的代码执行此操作,但它会删除 div#off 中的所有内容
。如何让 iframe
设置在 div#off
内容的底部而不是删除所有内容?是否可以?
$(document).ready(function() {
$("#off").html("<iframe src='http://images.findel-education.co.uk/EmailSignup/website_email_sign_up.html'>></iframe>");
});
我无法控制父窗口,所以我必须这样做。
最佳答案
.html()
将替换您元素的所有当前 HTML 标记,您想使用 .append() 改为:
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
$(document).ready(function() {
$("#off").append("<iframe src='http://images.findel-education.co.uk/EmailSignup/website_email_sign_up.html'>></iframe>");
});
关于javascript - 将 iframe 插入到 div 的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22378997/