JQuery colorplugin stops CSS: freezes

I am using jQuery plugin. I have an element lithat, when frozen, changes the background color. He does this using the standard CSS CSS alias in the :hoverCSS file. This works great until I use the color plugin on it - the effect :hoverjust stops working when I โ€œpulsateโ€ an element using this code:

$(".elements").first()
              .delay(400)
              .css({ backgroundColor: '#eeeeee' })
              .animate({ backgroundColor: '#888888' }, 2000);

Can someone suggest a solution so that when the โ€œmomentumโ€ is displayed, the original behavior :hovercontinues to work?

+3
source share
3 answers

:hover !important, , JavaScript , .

+7

- , :

$(".elements").hover(function(){
  $(this).stop().removeAttr('style')},
function(){
  $(".elements").first().delay(400).css({backgroundColor: '#eeeeee'}).animate({backgroundColor: '#888888'}, 2000);
});

css :

li:hover {
  background:red !important;
}
+2

The problem is the explicit background color specified by the element that overrides CSS. At the end of the animation, clear the background color as follows:

$(".elements").first()
    .delay(400)
    .css({backgroundColor: '#eeeeee'})
    .animate({backgroundColor: '#888888'}, 2000, function() {
        $(this).css({backgroundColor: ''});
    });

Working example: http://jsfiddle.net/SyqSf/

0
source

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


All Articles