There was a problem with the Botsrapovsky slider, I have several of them on the page, they can be added through the database and the problem is that I need to switch between all the carousels on this page using the "prev." and "nekst", but I do not know how to do it so that it takes a slide from the next slider
- here is the code slider jsfiddle.net/fmbwqqt4 - Andrey Kekc
- 1) The code is hard to read. Put indentation and blank lines, please. 2) Refine the task. Does the user click the “next” button, and when he reaches the last slide in the carousel, he flips it over to the next carousel? - Gleb Kemarsky
- Yes, just slides from the next slider are picked up slides - Andrey Kekc
- What does "just pick up" mean? On the page there are several sets of slides, but where would you start turning them over, will you see all the slides from all the sets? - Gleb Kemarsky
- Yes, I open slider 1 slides from it open and when flipping through slides, slides from this slider start scrolling and then slides from the next one are picked up and so on with everyone - Andrey Kekc
1 answer
If I understood your task correctly, it can be solved by filling in all the carousels with the same sets of slides. This set will contain all slides from all roundabouts.
Since your code collects carousels without indicators and backward / forward arrows, carousels will differ only in which slide has the class active .
And your carousel does not need identifiers. They are used by indicators and arrows, which you do not have.
Php
Processing the query to the database, you must first fill in all the carousels with all the slides, and then display them on the screen.
You can count the number of records in the query and create an array with the same number of rows. Processing each record from the request, it is necessary to add the next portion of slides to all elements of the array. And at the right moment to assign the class active first slide of the next set.
jQuery
You can write a script that, after loading the page, goes through all the carousels and complements them with clones of slides from other carousels. You will need jQuery methods:
- http://jquery-docs.ru/core/each/
- http://jquery-docs.ru/manipulation/clone/
- http://jquery-docs.ru/manipulation/appendto/
- http://jquery-docs.ru/Manipulation/prependTo/
For example, first go through all the slides in all the carousels and collect an array of matches {slide number on the page <-> carousel number on the page}. Then go through the array, cloning the slides.
- @AndreyKekc Updated his answer. Since your code collects carousels without indicators and arrows, it will be relatively easy to change the php code so that it immediately fills all the carousels with all possible slides and assigned slides from which each carousel should start. - Gleb Kemarsky 7:09 pm