

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to animate scrollLeft using jQuery?
To animate scrollLeft using jQuery, use the animate() method with scrollLeft.
Example
You can try to run the following code to learn how to animate scrollLeft using jQuery:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('#scrollme').click(function() { $('html,body').animate({ scrollLeft: $('#demo').css('left') }, 500, function() { $('html, body').animate({ scrollLeft: 0 }, 500); }); }); }); </script> <style> #demo { width: 100px; height: 100px; background: green; position: relative; left: 800px; } </style> </head> <body> <p><button id="scrollme">Click to scroll left</button></p> <div id="demo"></div> </body> </html>
- Related Questions & Answers
- How to implement jQuery ScrollLeft with easing?
- How animate(), hide and show elements using jQuery?
- How to animate a change in background color using jQuery on mouseover?
- How to animate buttons using CSS?
- HTML DOM scrollLeft Property
- How to Animate Bullets in Lists using CSS
- How to change CSS using jQuery?
- How to validate email using jQuery?
- How to animate text in Matplotlib?
- How to remove disabled attribute using jQuery?
- How to apply CSS properties using jQuery?
- How to clone an element using jQuery?
- How to duplicate a div using jQuery?
- How to remove event handlers using jQuery?
- How to disable right click using jQuery?
Advertisements