Prev Demo
Bootstrap
>
Carousel With Javascript
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <style> .carousel-inner > .item > img, .carousel-inner > .item > a > img { width: 70%; margin: auto; } </style> </head> <body> <div class="container"> <h2>Activate Carousel with JavaScript</h2> <div id="myCarousel" class="carousel slide"> <ol class="carousel-indicators"> <li class="item1 active"></li> <li class="item2"></li> <li class="item3"></li> <li class="item4"></li> </ol> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="http://www.techfunda.com/HTPictures/Generics/4-635880948886969785.jpg" alt="apple" height="200" width="300" /> <div class="carousel-caption"> <h3>Apple</h3> <p style="color: black">Am Apple with Red color</p> </div> </div> <div class="item"> <img src="http://www.techfunda.com/HTPictures/Generics/4-635981168904289706.jpg" height="200" width="300" /> <div class="carousel-caption"> <h3>Mango</h3> <p style="color: black">Am mango with yellow color.</p> </div> </div> <div class="item"> <img src="http://www.techfunda.com/HTPictures/Generics/4-635981170705720902.jpg" height="200" width="300" /> <div class="carousel-caption"> <h3>Pomogranite</h3> <p style="color: black">AM pomogranite with red color </p> </div> </div> <div class="item"> <img src="http://www.techfunda.com/HTPictures/Generics/4-635981167485980823.jpg" height="200" width="300" /> <div class="carousel-caption"> <h3>Gauva</h3> <p style="color: black">Am gauva with green color </p> </div> </div> </div> <a class="left carousel-control" href="#myCarousel" role="button"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#myCarousel" role="button"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </div> <script> $(document).ready(function () { $("#myCarousel").carousel(); $(".item1").click(function () { $("#myCarousel").carousel(0); }); $(".item2").click(function () { $("#myCarousel").carousel(1); }); $(".item3").click(function () { $("#myCarousel").carousel(2); }); $(".item4").click(function () { $("#myCarousel").carousel(3); }); $(".left").click(function () { $("#myCarousel").carousel("prev"); }); $(".right").click(function () { $("#myCarousel").carousel("next"); }); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output