Help in jQuery

This does not work. I am trying to repeat the animation until red, and then remove the effect, as in the WordPress admin. The item is deleted, but before that it is not animated.

$('.delete-item').live('click', function(){
            $(this).parent().parent().animate({backgroundColor: '#ff0000'}, 'slow').empty().remove();
        });
+3
source share
2 answers

As I know, you cannot animate the background color , you need a color plugin to do this.

+3
source

Use a .animate()callback, for example:

$('.delete-item').live('click', function(){
  $(this).parent().parent().animate({backgroundColor: '#ff0000'}, 'slow', function() {
    $(this).empty().remove();
  });
});

The callback will not be executed until the animation is completed, your current method finishes the animation, but only performs one frame before the element is removed from the DOM, this will allow the entire animation to be executed and delete it.

+1
source

Source: https://habr.com/ru/post/1743608/


All Articles