我正在尝试创建带有选项卡式浏览的网站,并按照教程进行操作。但是问题是我当前正在使用的代码确实能按预期工作。
HTML代码:
http://pastebin.com/CG146NS3
CSS代码:http://pastebin.com/4VCuAwJm
JavaScript:http://pastebin.com/sZhhQs6v
我遵循的教程:http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/
问题:
当我单击选项卡之一时,#content随slideUp消失,.load加载内容,但确实将内容放置在#content中。
最佳答案
您有一些重复的#ids
。
请记住,当您这样做时:
var toLoad = $(this).attr('href')+' #content';
// other execution
function loadContent() {
$('#content').load(toLoad,function(){
$('#content').slideDown('normal');
});
您实际上是将页面片段
#content
加载到页面的#content
中。因此,您最终得到以下结果:<div id='content'>
<div id='content'>Random Data</div>
</div>