Jquery animate scrollLeft bug in IE and FF

2019-02-20 16:47发布

问题:

I trying animate a horizontal scroll, but get a litle bug in IE and FF, when click to scroll, gets a "flash" looks like a ghost of previous divs. Its hard to explain in words, see the example in http://amplabusca.org/teste2/ementa.php

Why does this happen?

回答1:

Change your click-Event to something like $('#next').click(function (event) { event.preventDefault(); // Your code... }); to prevent the "move to anchor" standard behavior.

$('#next').click(function(event) {
    event.preventDefault();
    margin +=width;
    $('html, body').stop().animate({scrollLeft:"+="+500},1000);
    $("#prev a").css('visibility','visible');
});