引入css,js:
<link rel="stylesheet" type="text/css" href="./css/style.css"> <scriptt type="text/javascriptt" src="./scriptts/jquery-1.9.1.js"></scriptt> <scriptt type="text/javascriptt" src="./scriptts/carousel.js"></scriptt>
配置插件:
$(".carousel-content").carousel({ carousel: ".carousel", //轮播图容器 indexContainer: ".img-index", //下标容器 prev: ".carousel-prev", //左按钮 next: ".carousel-next", //右按钮 timing: 3000, //自动播放间隔 animateTime: 700, //动画时间 autoPlay: true, //是否自动播放 true / false direction: "left", //滚动方向right / left });
若需要作用翻页按钮的动画按钮,加入如下代码:
$(".carousel-content").hover(function() { $(".carousel-prev,.carousel-next").fadeIn(300); }, function() { $(".carousel-prev,.carousel-next").fadeOut(300); }); $(".carousel-prev").hover(function() { $(this).find("img").attr("src", "./images/left2.png"); }, function() { $(this).find("img").attr("src", "./images/left1.png"); }); $(".carousel-next").hover(function() { $(this).find("img").attr("src", "./images/right2.png"); }, function() { $(this).find("img").attr("src", "./images/right1.png"); });
有问题可联系作者 QQ:1057503612
<script type="text/javascriptt" src="./scripts/jquery-1.9.1.js"></script> <script type="text/javascriptt" src="./scripts/carousel.js"></script>
这里有点小错 应该是吧