2011-01-12 176 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