开发者

jQuery scrollLeft

开发者 https://www.devze.com 2023-02-13 19:07 出处:网络
I was looking at the tutorial at http://jqueryfordesigners.com/jquery-infinite-carousel/. I tried creating something similar myself for understanding, it turned out to be more complex than I thought.

I was looking at the tutorial at http://jqueryfordesigners.com/jquery-infinite-carousel/. I tried creating something similar myself for understanding, it turned out to be more complex than I thought. How do I use scrollLeft?

I created a simple fiddle to test it http://jsfiddle.net/sryKu/2/

<div id="carousel">
    <div class="wrapper">
        <ul>
            <li><a href="#">Test Link 1</a></li>
            <li><a href="#">Test Link 2</a></li>
...

CSS

#carousel .wrapper {
    position: relative;

ul {
    position: 开发者_如何学JAVAabsolute;

JS

$wrapper.scrollLeft(itemsPerPage * itemWidth);

But its not scrolling


You will have to use animate method for that:

$wrapper.animate({scrollLeft: itemsPerPage * itemWidth});
0

精彩评论

暂无评论...
验证码 换一张
取 消