Answer the question
In order to leave comments, you need to log in
How to make jquery slider without plugins?
How to write a simple jQuery slider without buttons, with automatic scrolling?
I understand that it’s easier to download a ready-made one, but I’m interested in the very essence of how it is written.
HTML
<div class="slider">
<ul class="slider__list">
<li class="slide active">
<img src="img/bg/first-bg.png" alt="first-bg">
<span class="slide__title">a v e</span>
<button class="slide__btn btn">shop men’s collection</button>
</li>
<li class="slide">
<img src="img/bg/first-bg.png" alt="first-bg">
<span class="slide__title">a v e</span>
<button class="slide__btn btn">shop men’s collection</button>
</li>
<li class="slide">
<img src="img/bg/first-bg.png" alt="first-bg">
<span class="slide__title">a v e</span>
<button class="slide__btn btn">shop men’s collection</button>
</li>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
Well, how. All slides are hidden, then the first one is shown. Then the second is hidden and shown. And so in a circle.
The simplest option that came to mind is to use setTimeout or a loop. Without considering the development of flipping for myself, I won’t say for sure, I haven’t matured yet.
We get the position of the parent block (.slider), for example, 400x400, we get the position of the active slide (.slide .active) of the same size (to make it easier to perceive), we shift the strip (.slider__list) with slides to this position. All this in a set timeout (recursive), settimer or loop, but these are offhand thoughts.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question