jQuery 使用jquery将外部html文件加载到div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8849668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
load external html file to div using jquery
提问by Sowmya
I am using a html page which has many tooltips. each tooltip has a gallery, since it is not possible to use multiple gallery which has same id, I am planning to create 6 different html files for gallery, then load the gallery into my default page.
我正在使用一个包含许多工具提示的 html 页面。每个工具提示都有一个画廊,因为不可能使用多个具有相同 ID 的画廊,我计划为画廊创建 6 个不同的 html 文件,然后将画廊加载到我的默认页面中。
I need to cal the html page for each div. I tried .load but it is not working.
我需要为每个 div 调用 html 页面。我试过 .load 但它不起作用。
<div id="flrmain">need to call the html file inside this div.<div>
Please help.
请帮忙。
回答by Skyrim
$.get('test.html')
.success(function(data) {
$('div.content').html(data);
});
EDIT
编辑
If you need it for that specific div
, replace 'div.content'
with '#flrmain'
.
如果您需要特定的内容div
,请替换'div.content'
为'#flrmain'
.