79166255

Date: 2024-11-07 11:39:15
Score: 0.5
Natty:
Report link
// Get the scroll container element
const scrollContainer = document.querySelector('.scroll-container');

// Get the buttons
const scrollLeftButton = document.getElementById('scrollLeft');
const scrollRightButton = document.getElementById('scrollRight');

// Set the amount to scroll per click (in pixels)
const scrollAmount = 200;  // Adjust this value as needed

// Add event listener to the "Scroll Left" button
scrollLeftButton.addEventListener('click', function() {
  scrollContainer.scrollLeft -= scrollAmount;  // Scroll to the left
});

// Add event listener to the "Scroll Right" button
scrollRightButton.addEventListener('click', function() {
  scrollContainer.scrollLeft += scrollAmount;  // Scroll to the right
});
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user28179436