For example let's say that I have a div element with 100%
width and 100px
height. Inside that div I have 6 div elements floated left, with overflow-x
enabled. What I want to achieve is, that user can scroll through loop of these divs (so that last div element is followed by first - infinite loop).
Any idea how to approach?
You can use jQuery insertAfter
and insertBefore
functions
$('.next').click(function(){
var last = $('#parent').find('div').last();
$('#parent').find('div').first().insertAfter(last);
});
$('.prev').click(function(){
var first= $('#parent').find('div').first();
$('#parent').find('div').last().insertBefore(first);
});
Here is the DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With