我主要通過學習其他人的代碼來學習jQuery。我發現這個腳本http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/。jQuery:在哪裏放分號?
我已經改變了一點,所以我得到這個代碼:
$(document).ready(function() {
$('nav li a').click(function() {
var toLoad = $(this).attr('href')+' article';
$('article').fadeOut('slow',loadContent);
function loadContent() {
$('article').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('article').fadeIn('slow');
}
return false;
});
});
現在很多的問題後,我發現整個事情不工作,當我把一個分號後「showNewContent())」。爲什麼會發生?我的第二個問題是,爲什麼他只用「loadContent」而不是函數「showNewContent」和「showNewContent()」(用括號)啓動函數「loadContent」?
分號是換行符。你爲每個分號執行一個命令。我猜jQuery在這方面有點混亂,因爲你可以把事情鏈接在一起。 – Chamilyan
我是寫這個問題的人。首先感謝所有想要幫助的人。我想我的問題是我的瀏覽器緩存,這似乎需要刪除。再次感謝! – Mausoleum