jQuery将外部html文件附加到我的页面中 [英] jquery append external html file into my page

查看:41
本文介绍了jQuery将外部html文件附加到我的页面中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以这种方式附加外部html内容(div加上一些文本以供测试):

I'm trying to append an external html content (div plus some text inside just for testing) this way:

$.get("banner.html", function(data){
    $(this).children("div:first").append(data);
});

这似乎很简单...但是似乎不起作用.任何的想法?谢谢!

That seems to be pretty simple... but it does not seem to work. Any idea? Thanks!

推荐答案

使用html而不是追加:

Use html instead of append:

$.get("banner.html", function(data){
    $(this).children("div:first").html(data);
});

这篇关于jQuery将外部html文件附加到我的页面中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆