Answer the question
In order to leave comments, you need to log in
How to correctly set the block in which the script should find the buttons?
I connected two owl carousels and it looks like this:
$(document).ready(function() {
$('.carousel').each(function(){
var carousel = $(this);
carousel.owlCarousel({
loop:true,
margin:10,
nav:false,
dots:false,
items: 1,
responsive:{
0:{
items:1
},
600:{
items:3
},
1000:{
items:5
}
}
});
carousel.next().find(".customNextBtn").on('click', function(){
carousel.trigger("next.owl.carousel");
});
carousel.next().find(".customPreviousBtn").on('click', function(){
carousel.trigger("prev.owl.carousel");
});
});
});
carousel.next().find(".customNextBtn").on('click', function(){
carousel.trigger("next.owl.carousel");
});
carousel.next().find(".customPreviousBtn").on('click', function(){
carousel.trigger("prev.owl.carousel");
});
you need to tell the script to look for these buttons in a block with a specific id, for example "#films", and wrap them in id=films Answer the question
In order to leave comments, you need to log in
The problem is that when the buttons customPreviousBtn and customNextBtn are located above the carousel, they do not work, but when they are below, they work.
carousel.next()
, then you take the adjacent "to the right" of the '.carousel'
DOM element, i.e. the one that, according to the DOM structure, goes immediately after '.carousel'
'.carousel'
, i.e. according to the DOM structure, it comes immediately before '.carousel'
carousel.prev().find(".customNextBtn").on('click', function(){
carousel.trigger("next.owl.carousel");
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question