2011-01-12 180 views
0

我试图创建一个带有标签浏览的网站,并且遵循了一个教程来做到这一点。但问题是,我目前的代码正在按预期使用doesent工作。使用jQuery加载外部.html文件

的教程中,我跟着:http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/

问题: 当我单击其中一个选项卡时,#content会使用slideUp和.load加载内容,但它不会将内容放置在#content中。

+0

你的外部文件在同一个网络服务器上? – justkt 2011-01-12 16:31:37

+0

你可以发布你的`random1.html`吗? – ifaour 2011-01-12 17:53:35

回答

2
  1. 您有一些副本#ids
  2. 记住,当你这样做:

    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> 
0

好了,根据您的comment..Just确保您实际上有一个div与您的随机HTML文件ID #content