2012-05-28 59 views
0

所以我這樣的:jQuery函數調用

function pageSwap(menuPont){ 
    $(".content").fadeOut("1000",function(){ 
      $(".content").load(menuPont, function(){ 
       $(".content").fadeIn("5000"); 
      });  
    }); 
} 

上的index.php,也是這個

$(".content").ready(function(){pageSwap('main.html')}); 

工作和東西,但我的問題是,我需要調用pageSwap( 'other.html')
IN THE。內容的div,鏈接樣式。

我不能得到這個工作,所以請幫助我。 :[

+0

'.content div'是什麼意思? – 11684

+0

你究竟做了什麼,它是如何失敗的? – lanzz

+0

我需要調用位於.container div中的包含文件中的pageSwap函數(位於index.php中)。 :D 我試過onclick =「function(){pageSwap blah」,複製函數等等。不工作。 :( –

回答

1

我不能完全確定什麼都想做到的,但我認爲你要調用pageSwap(「other.html」),當有人點擊。內容的div?

$(function(){ 
    pageSwap('main.html'); 
    $('.content').click(function(){ 
    pageSwap('other.html'); 
    } 
}); 

與註釋的解決方案更新時間: 要調用pageSwap(「other.html」)在容器內的點擊鏈接時,把函數調用到HREF:

<a href="javascript:pageSwap('other.html');">my link</a> 
+0

差不多,我希望當有人點擊的div容器中的鏈接來進行交換,但它是一個問題,因爲容器div包含的jQuery包括了網頁。 –

+0

怎麼樣添加函數調用鏈接的href?my link 。這是否工作? – aaberg

+0

謝謝!這很好:DD –