This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center。
已关闭8年。
我主要通过学习其他人的代码来学习jQuery。
我发现此脚本http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/。
我做了一些更改,所以得到了以下代码:
现在,在遇到许多问题之后,当我在“ showNewContent())之后加上分号时,我注意到整个事情都不起作用。为什么会这样呢?
我的第二个问题是,为什么他只用“ loadContent”启动函数“ loadContent”,而用“ showNewContent()”(带有括号)启动函数“ showNewContent”?
顺便说一句,您不需要传递第二个参数。使用此代替:
已关闭8年。
我主要通过学习其他人的代码来学习jQuery。
我发现此脚本http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-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”启动函数“ loadContent”,而用“ showNewContent()”(带有括号)启动函数“ showNewContent”?
最佳答案
错了该行应为:
$('article').load(toLoad, '', showNewContent);
顺便说一句,您不需要传递第二个参数。使用此代替:
$('article').load(toLoad, showNewContent);
关于javascript - jQuery:在哪里放置分号? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7323879/