<< All Posts
How to scroll window to the left or right using jQuery


Hey

I’m posting this information because I spent some hours to make this working fine in Firefox and Safari. We can find on google a lot of examples to scroll window or div elements up or down. But left or right isn’t so easy.

<script type="text/javascript">  
        $(function() 
                {
                $("#moveLeft").click(function() {
                    $("html, body").animate({ scrollLeft: '-=500px' }, "slow");
                });

                $("#moveRight").click(function() { 
                    $("html, body").animate({ scrollLeft: '+=500px' }, "slow");
                });
        });            
</script>



<< All Posts

rodolfo.io

🇧🇷 🇨🇦
Runs on OpenBSD 🐡