Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
Disable scroll button until fully scrolled

https://codepen.io/ha26ktan/pen/oNoQGEO

I built a website with my minimal - intermediate level of css and html knowledge. I have 2 buttons. One of them is for scrolling to the right and the other to the left. This scrolling is according to the width of a divin column.

When the right or left button is pressed repeatedly, the command is triggered again without waiting for the distance to go, and this causes it to stay outside the required distance.

How can I disable both buttons until they switch to the other column? Thank you very much in advance.

`const kitapp = document.getElementById('kitapp');

document.getElementById("btnLeft").onclick = () => {
  kitapp.scroll({
    left: kitapp.scrollLeft + kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
}
     
document.getElementById("btnRight").onclick = () => {
  kitapp.scroll({
    left: kitapp.scrollLeft - kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
}`

const kitapp = document.getElementById('kitapp');

document.getElementById("btnRight").onclick = () => {
document.getElementById("btnRight").disabled = true;
  kitapp.scroll({
    left: kitapp.scrollLeft + kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
setTimeout(enableButon1, 1000);

}
 
document.getElementById("btnLeft").onclick = () => {
document.getElementById("btnRight").disabled = true;
  kitapp.scroll({
    left: kitapp.scrollLeft - kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
setTimeout(enableButon2, 1000);
  
}

function enableButon1() {
     document.getElementById("btnLeft").disabled = false;
}
function enableButon1() {
    document.getElementById("btnRight").disabled = false;
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can try to disable the button once you click on it, you can use

document.getElementById("btnLeft").disabled = true;

once you click on it. It can look like this:

const kitapp = document.getElementById('kitapp');

document.getElementById("btnLeft").onclick = () => {
  kitapp.scroll({
    left: kitapp.scrollLeft + kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
document.getElementById("btnLeft").disabled = true;
}
 
document.getElementById("btnRight").onclick = () => {
  kitapp.scroll({
    left: kitapp.scrollLeft - kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
  document.getElementById("btnRight").disabled = true;
}

I think this should work for you, but you will need to enable the button later, making a timer for example, or enabling it when you click the other button.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Then you can try to make like this: When you click on the button, you can disable it

const kitapp = document.getElementById('kitapp');

document.getElementById("btnLeft").onclick = () => {
document.getElementById("btnLeft").disabled = true;
  kitapp.scroll({
    left: kitapp.scrollLeft + kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
setTimeout(enableButon1, 1000);

}
 
document.getElementById("btnRight").onclick = () => {
document.getElementById("btnRight").disabled = true;
  kitapp.scroll({
    left: kitapp.scrollLeft - kitapp.querySelector(".deneme").offsetWidth,
    behavior: 'smooth'
  });
setTimeout(enableButon2, 1000);
  
}

function enableButon1() {
     document.getElementById("btnLeft").disabled = false;
}
function enableButon1() {
    document.getElementById("btnRight").disabled = false;
}

I hope this one works for you.

You can change the time it waits changing the value of setTimeout(enableButon2, 1000); and put the number you want to wait.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda