jQuery .animate() callback infinite loop

前端 未结 5 879
我在风中等你
我在风中等你 2021-02-10 23:54

A simple question: Why can I do this

var start = function() {
    $(\'#element\').animate({}, 5000, \'linear\', start);
}

but not this

5条回答
  •  抹茶落季
    2021-02-11 00:38

    In the second example, you are basically doing a recursive call to start().

    What you want to do is pass the function start itself, like you are doing in your first example. Your second example is only providing the result of calling start().

提交回复
热议问题