没有调用递归

Recursion not being called

本文关键字:递归 调用      更新时间:2023-09-26

谁能帮我把这一小段代码递归地调用自己?它只触发一次,然后停止,不做任何动画。我想做的是在人们分享了他们的地理位置之后,递归地在图像元素上动画化一个边界。此代码位于document.ready中。

(function pulse(){
    console.log('hello world');
    $('.contacts-list li.closest img')
        .delay(1000)
        .animate({ 'border-color': 'transparent'}, 100)
        .delay(500)
        .animate({ 'border-color': 'rgb(147, 190, 104)'}, 100, pulse);
})();   

试试这个

(function pulse(){
    console.log('hello world');
    $('.contacts-list li.closest img')
        .delay(1000)
        .animate({ 'border-color': 'transparent'}, 100)
        .delay(500)
        .animate({ 'border-color': 'rgb(147, 190, 104)'}, 100, function() 
        {
            pulse();
        });
})();