JQuery & # 8594; item search and navigation system?
I wonder how I can solve the following problem.
I have a horizontal scrollbar with floating divs side by side (.picture_holder). I wonder if I can find () these elements and animate the scroll event to the start point of each image. If I go to the last div i to go to the first.
#
$('.next').click(function(){
#
$('html, body').animate({scrollTo:Position von .picture_holder2}, 'slow');
#
});
?? any ideas how i could solve this?
+2
a source to share
2 answers
You can scroll horizontally to position using jQuery function .scrollLeft()
.
http://api.jquery.com/scrollLeft/
If you want to animate it, do the following:
Live example: http://jsfiddle.net/b5Xps/
$('.next').click(function(){
// Get left offset position of the target
var leftPosition = $('.picture_holder2').offset().left;
// animate the scrollLeft property to that position
$('html,body').animate({scrollLeft: leftPosition }, 1000);
});
0
a source to share