jQuery如何加载一些html并将其附加到< body>元素? [英] How can jQuery load some html and append it to the <body> element?
本文介绍了jQuery如何加载一些html并将其附加到< body>元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了以下操作:
$.load("Views/chatBox.html").appendTo('body')
控制台输出:
TypeError: $.load is not a function
编辑:答案只能是一行代码;我想就足够了.
EDIT: The answer should only be one line of code; that's enough, I think.
推荐答案
我不明白为什么不需要将容器放在主体底部并将外部页面加载到其中?
I dont understand why placing container at the bottom of body and loading external page into that is not what you need?
您可以尝试的是这样:
<script type="text/javascript">
$(function() {
$("#container").load("Views/chatBox.html",function(){
$(this).clone().appendTo("body").remove();
});
});
</script>
但是我不是100%知道此代码...:)
But im not 100% sure about this code... :)
这篇关于jQuery如何加载一些html并将其附加到< body>元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文