Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda