Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!