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

131
Vistas
JQuery scrollLeft still show zero

I have easy code I want to use to us arrows instead of scroll bar but I have problem sith scrollLeft function. It stll shows me zero. Can you advice me what can be problem?

/* SIDE SCROLL */

var leftOffset = $('.categories__list').scrollLeft();

$('.right-arrow').click(function () {
    event.preventDefault();
    alert(leftOffset);

})

This is my code on index.php:

    <section class="categories">
        <ul class="categories__list">
            <a href="" class="left-arrow"></a>
            <li class="categories__items">
                <ul class="categories__list-nested">
                    <li class="categories__items-img"><a href="categories__link"><img src="/bazar/assets/img/pocitace.png" alt="" class="categories__img"></a></li>
                    <li class="categories__items-nested"><strong><a href="categories__link">Počítače</a></strong></li>
                    <li class="categories__items-nested"><a href="categories__link">Počítače</li></a>
                    <li class="categories__items-nested"><a href="categories__link">Monitory</li></a>
                    <li class="categories__items-nested"><a href="categories__link">Notebooky</li></a>  
                </ul>
            </li>
         </ul>
     </section>

UDPATE:

I made it by this way finally:

    var scrollEnd = $('.categories__list').width();

    $('.right-arrow').click(function () {
        event.preventDefault(); 
        $('.categories__list').animate({scrollLeft: scrollEnd}, 1000)
    })

    $('.left-arrow').click(function () {
        event.preventDefault();
        $('.categories__list').animate({scrollLeft: 0}, 1000)
    })

I was confused bcz on w3school example for scrollLeft they used alert and it was working.

about 4 years ago · Juan Pablo Isaza
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