jQuery “blinking highlight” effect on div?

后端 未结 15 1052
囚心锁ツ
囚心锁ツ 2020-12-04 09:24

I\'m looking for a way to do the following.

I add a

to a page, and an ajax callback returns some value. The
is fill
相关标签:
15条回答
  • 2020-12-04 10:20

    just give elem.fadeOut(10).fadeIn(10);

    0 讨论(0)
  • 2020-12-04 10:22

    Since I don't see any jQuery based solutions that don't require extra libraries here is a simple one that is a bit more flexible than those using fadeIn/fadeOut.

    $.fn.blink = function (count) {
        var $this = $(this);
    
        count = count - 1 || 0;
    
        $this.animate({opacity: .25}, 100, function () {
            $this.animate({opacity: 1}, 100, function () {
                if (count > 0) {
                    $this.blink(count);
                }
            });
        });
    };
    

    Use it like this

    $('#element').blink(3); // 3 Times.
    
    0 讨论(0)
  • 2020-12-04 10:22

    I think you could use a similar answer I gave. You can find it here... https://stackoverflow.com/a/19083993/2063096

    • should work on all browsers as it only Javascript and jQuery.

    Note: This solution does NOT use jQuery UI, there is also a fiddle so you can play around to your liking before implementing it in your code.

    0 讨论(0)
提交回复
热议问题