jQuery .animate() callback infinite loop

前端 未结 5 649
余生分开走
余生分开走 2021-02-11 00:18

A simple question: Why can I do this

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

but not this

5条回答
  •  礼貌的吻别
    2021-02-11 00:42

    it's because in the first one you are sending the namespace of the function, when you add the () to the end of the function name it executes the function immediately

提交回复
热议问题