为什么我不能将javascript函数与jquery方法混合使用?

Lau*_*182 -3 javascript jquery

我很擅长使用jQuery(我很喜欢常规的js),而且我很难过,真的很难过,想弄明白这一点,我已经读了几天,因为我经常发现我自己的答案,但这已经走得太远了.

我不知道,为什么,这样编码时:

$(document).ready(slideShow());

function slideShow() {
    alert("enters");
    $('ul.imgslider').each(function () {
        $('li', this).css("display", "block");
        $('li', this).fadeOut(1000);
    });
};
Run Code Online (Sandbox Code Playgroud)

警报已执行,但.each()未执行.如果你这样编码:

$(document).ready(function slideShow() {
    alert("enters");
    $('ul.imgslider').each(function () {
        $('li', this).css("display", "block");
        $('li', this).fadeOut(1000);
    });
});
Run Code Online (Sandbox Code Playgroud)

一切都在执行.我只是不明白,我想知道为什么会这样?更奇怪的是,在jsfiddle中它确实被执行了,但是当我在本地运行它时却没有.我正在使用jquery-2.0.3.min.js.

Nie*_*sol 10

因为立即$(document).ready(slideShow())调用,并将其返回值传递给函数.slideShow ready

$(slideShow);
Run Code Online (Sandbox Code Playgroud)

这是应该怎么做;)