0

I am trying to create a little client slide with javascript. What i have achieved so far is to move the images om button click. Below is the code

HTML

<div class="client-slide">
    <img src="images/oma.png">
    <img src="images/pz.png">
    <img src="images/tata.png">
    <img src="images/mik.png">
    <img src="images/may.png">
    <img src="images/dang.png">
    <img src="images/vita.png">
    <img src="images/cap.png">
    <img src="images/cla.png">
    <img src="images/int.png">
</div>
<ul class="slideBtn">
    <li><div class="leftButton"><i class="fa fa-angle-left"></i></div></li>
    <li><div class="rightButton"><i class="fa fa-angle-right"></i></div></li>
</ul>

JavaScirpt

$(document).ready(function() {
    $('.leftButton').click(function() {
        $('.client-slide').animate({
            'marginLeft' : "-=100px"
        });
    });
    $('.rightButton').click(function() {
        $('.client-slide').animate({
            'marginLeft' : "+=100px"
        });
    });
});

Above code work when i click on the button. I want such that when i click on the button, the image in position one goes to the last position there by creating an infinite loop.

Thanks.

diagold
  • 493
  • 1
  • 7
  • 28
  • I once created a slider as an answer on stackoverflow. Maybe this can help you: https://stackoverflow.com/questions/39673540/an-infinite-carousel-with-vanilla-javascript/39678409#39678409 – Tobi Obeck Dec 10 '17 at 13:15
  • I suggest you create a fiddle or code snippet including the css – Eddie Dec 10 '17 at 13:17
  • Stackoverflow isn't a free code writing service. There are hundreds of carousel/slider scripts and tutorials all over the web you could study to figure this out – charlietfl Dec 10 '17 at 13:18
  • You can easily use **Owl Carousel** or anything else.. – Pedram Dec 10 '17 at 13:20
  • @charlietfl this i know already. I wouldn't ask if i have not tried already. – diagold Dec 10 '17 at 13:20
  • Tried what ? I see absolutely no attempt shown to do what you are asking. Rather it seems you just want someone to code a carousel for you when you could simply get a working one yourself – charlietfl Dec 10 '17 at 13:21
  • @pedram i know about owl carousel. That's an option. Just trying to figure this out. – diagold Dec 10 '17 at 13:21
  • @charlietfl tried with a `for` loop. would update now. – diagold Dec 10 '17 at 13:22
  • @diagold So better provide a live demo of what you tried so far – Pedram Dec 10 '17 at 13:23
  • **[How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users?s=1|81.5729)** – charlietfl Dec 10 '17 at 13:24

0 Answers0