[英]Load in external .html file with jQuery
I'm trying to create a website with tabbed browsing and have followed a tutorial to make this. 我正在尝试创建带有选项卡式浏览的网站,并按照教程进行操作。 But the problem is that the code I'm currently is using doesent work as expected. 但是问题是我当前正在使用的代码确实能按预期工作。
HTML-code: http://pastebin.com/CG146NS3 HTML代码: http : //pastebin.com/CG146NS3
CSS-code: http://pastebin.com/4VCuAwJm CSS代码: http : //pastebin.com/4VCuAwJm
The tutorial I followed: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/ 我遵循的教程是: http : //net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/
The problem: When I click one of the tabs the #content goes away with a slideUp and .load loads the content but it doesent place the content in #content. 问题:当我单击其中一个选项卡时,#content随slideUp消失,.load加载了内容,但确实将内容放置在#content中。
#ids
. 您有一些重复的#ids
。 Remember when you do: 请记住,当您这样做时:
var toLoad = $(this).attr('href')+' #content'; // other execution function loadContent() { $('#content').load(toLoad,function(){ $('#content').slideDown('normal'); });
you are actually loading a page fragment #content
into #content
in your page. 您实际上是将页面片段#content
加载到页面的#content
中。 So you end up with this: 因此,您最终得到以下结果:
<div id='content'>
<div id='content'>Random Data</div>
</div>
好的,根据您的评论。只需确保您的随机html文件中确实有ID为#content
的DIv。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.