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

224
Views
Owl carousel checks item count for doing something

I have an owl carousel and I want to write a function which can check whether the number of items is equal to 1 and then disable corresponding navigation arrows.

Please help me do, this is what I tried (a function which will show number of items in the console and their respective index, but it isn't working)

 var owl = $('.owl-carousel').owlCarousel({
        loop: true,
        margin: 10,
        responsiveClass: true,
        dots: false,
        responsive: {
            0: {
                items: 1,
                nav: false,
            },
            767: {
                items: 2,
                nav: false
            },
            1000: {
                items: 3,
                nav: true,
                loop: false
            },
            onDragged  : callback
        }
    })

 function callback() {
        var items = event.items.count;
        var item = event.item.index;
        console.log(items,item);
    }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Let's try in this way:

 var owl = $('.owl-carousel').owlCarousel({
        loop: true,
        margin: 10,
        responsiveClass: true,
        dots: false,
        responsive: {
            0: {
                items: 1,
                nav: false,
            },
            767: {
                items: 2,
                nav: false
            },
            1000: {
                items: 3,
                nav: true,
                loop: false
            },
            onDragged  : callback
        }
    })


function callback(event) {
  var navValue = $(this).get(0).options.nav;
  console.log('Old nav value = ' + navValue);
  if (event.item.count == 1) {
    //if total count of items = 1 - we change value        
    navValue = false;
    //check if changed
    console.log('New nav value = ' + navValue);
  }
};
about 4 years ago · Juan Pablo Isaza Report

0

This can be done with an option:

loop: false

Does what you want.

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