如何使 jQuery 滑块仅滚动一项而不是三项?
我的网站上有一个 jQuery 滑块。我在此过程中使用了教程,但此滑块设置为滚动三个项目,但我希望它在单击时一次滚动一个项目。除此之外,它的工作效果非常好。
我发现这是因为“.pane”div 包装了两组三个项目(这是两个不同的无序列表)。但是,当我更改“.pane”以包装每个单独的项目(li)时,它不起作用。
关于解决这个问题的最简单方法有什么想法吗?
<div class="thumbnail_wrapper">
<div class="left-tab">
<img class="left" src="images/left-arrow.png" alt="Previous" />
</div>
<div class="holder">
<div class="home_slider">
<div class="pane"><ul>
<li class="post first showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
</ul></div><div class="pane"><ul>
<li class="post first showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
</ul></div>
<div class="clear"></div>
</div>
</div>
<div class="right-tab">
<img class="right" src="images/right-arrow.png" alt="Next" />
</div>
</div>
I've got a jQuery slider on my site. I used a tutorial in the process, but this slider is setup to scroll three items, but I would like it to just scroll one at a time onClick. Other than this, it works beautifully.
I see that this is because the ".pane" div wraps two sets of three items (which is two different unordered lists). However, when I change the ".pane" to wrap each individual item (li), it doesn't work.
Any thoughts on the easiest way to solve this?
<div class="thumbnail_wrapper">
<div class="left-tab">
<img class="left" src="images/left-arrow.png" alt="Previous" />
</div>
<div class="holder">
<div class="home_slider">
<div class="pane"><ul>
<li class="post first showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
</ul></div><div class="pane"><ul>
<li class="post first showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
<li class="post showDetails">
<a href="#"><img src="images/thumbnails/red.jpg" alt="" />
<div class="details_wrapper">
<div class="details">
<h3>Basketball Tournament</h3>
<h4>Visit Tournament Central</h4>
</div>
</div>
</a>
</li>
</ul></div>
<div class="clear"></div>
</div>
</div>
<div class="right-tab">
<img class="right" src="images/right-arrow.png" alt="Next" />
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
scrollOptions
变量中的items
属性更改为项目本身,例如,如演示中所示,更改为$('.thumbnail_wrapper .pane2')
:Change
items
property in thescrollOptions
variable to the items theirself, e.g. to$('.thumbnail_wrapper .pane2')
as in your demo: