Bootstrap Carousel Next / Prev不起作用 [英] Bootstrap Carousel Next/Prev not working

查看:72
本文介绍了Bootstrap Carousel Next / Prev不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Twitter Bootstrap Carousel,尽管我对.js不太熟悉,但是我还是可以正常工作。

I am working with Twitter Bootstrap Carousel and though I am not very familiar with .js, somehow I got things working fine.

唯一的问题是next / prev按钮以一种奇怪的方式工作。

The only problem is that the next/prev button is working in a strange way.

这是我的临时工网站:
http://tokyo-flaneur.com/dl/donner /contents/menu.html

Here's my temp site: http://tokyo-flaneur.com/dl/donner/contents/menu.html

虽然我有10张图片,但是我无法通过单击下一步按钮到达10号。在第三个图像之后,当我单击下一步按钮时,图像返回到No.2。

Although I have 10 images, I can not get to the No.10 by clicking the next button. After the third image, when I click on the next button, the image goes back to No.2.

此外,无论我要看哪个图像,当我单击prev按钮时,它都会一直返回到No.1。

Also, whichever image I am looking, when I click the prev button, it goes all the way back to No.1.

有人可以帮助我或将我引导到正确的方向吗?任何帮助将不胜感激。

Could anyone help me or direct me to the right direction? Any help would be appreciated.

推荐答案

您可以使用自己的处理程序来处理滑块的下一个/上一个按钮,因此它将滑动到第二个元素1st ,而不是尝试制作 next()

You handle slider's next/prev buttons with your own handler, so it slide to 2nd element 1st, than tries to make next()

替换:

$("#myCarousel a").click(function(e){ 
    var index = $(this).index(); 
    //when hitting NEXT button index always 2, for PREV - 0
    slider.carousel(index); 
    e.preventDefault(); 
}); 

$("#myCarousel .slider-pager a").click(function(e){ 
    var index = $(this).index(); 
    slider.carousel(index); 
    e.preventDefault(); 
}); 

在页面脚本中

这篇关于Bootstrap Carousel Next / Prev不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆