Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carousel bootstrap doesn't work

Someone can help me?I'm testing the bootstrap carousel but it doesn't work. Specifically: the previuos/next buttons don't work and the carousel doesn't slide to the next slide. this is my page's code but I don't know what I'm doing wrong.

<!DOCTYPE html>
<html>
<head>

<title>Title</title>

<!-- META -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- META -->

<!-- CSS -->
<link href="css/stile.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<!-- CSS -->  

</head>
<body>

<div class="container">

    <div id="myCarousel" class="carousel slide">

        <ol class="carousel-indicators">
            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
            <li data-target="#myCarousel" data-slide-to="1"></li>
            <li data-target="#myCarousel" data-slide-to="2"></li>
        </ol>

        <div class="carousel-inner">
            <div class="item active">
                <img src="image1.jpg" alt="image1.jpg">
            </div>
            <div class="item">
                <img src="image2.jpg" alt="image2.jpg">
            </div>
            <div class="item">
                <img src="image3.jpg" alt="image3.jpg">
            </div>
        </div>

        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
            <span class="icon-prev"></span>
        </a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next">
            <span class="icon-next"></span>
        </a>
    </div>
</div>

<!-- JS -->
<script src="//code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- JS -->
</body>
</html>
like image 821
Aleb95 Avatar asked Sep 09 '26 17:09

Aleb95


1 Answers

Have you called the Carousel with the below JS?

    $('.carousel').carousel({
  interval: 2000
})

Try putting the link/script at the top:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

These are embeded links and not from your root file. you can use yours but place them at the top and see if that helps.

like image 157
JoeyG Avatar answered Sep 12 '26 13:09

JoeyG