我无法在我的幻灯片旋转木马之间导航

时间:2017-01-04 19:01:22

标签: javascript html css slider carousel

我一直在为我的网站制作旋转木马。当我打开页面时,一切看起来都是正确的(图片显示,点已到位,下一个和上一个按钮显示)。但是当我尝试点击下一个或上一个时它没有做任何事情。我一直试图修复它一段时间,但我无法弄清楚出了什么问题。任何帮助都会很棒。

我的代码:

<div class="container">
    <div class = "row">
        <div class = "col-sm-12">

            <div id = "my-slider" class = "carousel slide" data-ride="carousel">

                <!--indicators dot nav -->
                <ol class="carousel-indicators">
                    <li data-target="#my-slider" data-slide-to="0" class = "active"></li>
                    <li data-target="#my-slider" data-slide-to="1"></li>
                    <li data-target="#my-slider" data-slide-to="2"></li>
                    <li data-target="#my-slider" data-slide-to="3"></li>
                    <li data-target="#my-slider" data-slide-to="4"></li>
                </ol>

                <!--Wrapper for slide -->
                <div class = "carousel-inner" role = "listbox">

                    <div class = "item active">
                        <img src = "image/img1.jpg" alt = "stuff"/>
                        <div class="carousel-caption">
                            <h1>header</h1>
                            <p>and paragraph</>
                        </div>
                    </div>

                    <div class = "item">
                        <img src = "image/img2.jpg" alt = "stupid stuff"/>
                        <div class="carousel-caption">
                            <h1>header</h1>
                            <p>and paragraph</>
                        </div>
                    </div>

                    <div class = "item">
                        <img src = "image/img3.jpg" alt = "other stuff"/>
                        <div class="carousel-caption">
                            <h1>header</h1>
                            <p>and paragraph</>
                        </div>
                    </div>

                    <div class = "item">
                        <img src = "image/img4.jpg" alt = "more stuff"/>
                        <div class="carousel-caption">
                            <h1>header</h1>
                            <p>and paragraph</>
                        </div>
                    </div>

                    <div class = "item">
                        <img src = "image/img5.jpg" alt = "last stuff"/>
                        <div class="carousel-caption">
                            <h1>header</h1>
                            <p>and paragraph</>
                        </div>
                    </div>
                </div>

                <!-- Controls -->
                <a class="left carousel-control" href="#my-slider" role = "button" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left" aria-hidden ="true"></span>
                    <span class = "sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#my-slider" role = "button" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right" aria-hidden = "true"></span>
                    <span class = "sr-only">Next</span>
                </a>

            </div>              
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:1)

你为什么要重新发明轮子?这就是框架存在的原因。每当您尝试应用组件时,只需查找框架即可。它将为您节省大量时间。我建议使用这个:jQuery thumbnail scroller

答案 1 :(得分:0)

这看起来像Bootstrap滑块中的示例代码。如果是这样,你需要确保bootstrap.js链接以及jQuery以使滑块工作。