Monitoring slideDown/Up eventsJQuery


  • QA Engineer

    There's a block. When he's in it, he's got a hidden block with a function. I'll use slideDown/Up in JQuery for my reflection. JS:

    $('li.block').hover(function () {
        $(this).find('div.info-block').slideDown();
    }, function () {
        $(this).find('div.info-block').slideUp();
    });
    

    And I noticed that thing. If you often start and take a courseor from the block, what has not yet been done, that is, slideDown/Up will be done as many times as we have. Example, for the explanation, I'll drive and clean 10 times fast. Then I clean up the cadet and until this block does slideDown/Up 10 times, it won't stop.

    Question. How can you fix this?



  • Stop the previous animation before the beginning of the new

    $('li.block').hover(function () {
    $(this).find('div.info-block').stop().slideDown();
    }, function () {
    $(this).find('div.info-block').stop().slideUp();
    });
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2