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

218
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

This can be done with an option:

loop: false

Does what you want.

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