新闻发布系统轮播效果
2017-05-08 08:14
351 查看
第一步,实现自动轮播
var index = 0;
var stop = false;
function xianshi() {
if (stop) {
return;
}
if (index < 3) {
index++;
} else {
index = 1;
}
$(".item img").attr("src", "image/img0" + index + ".png").show();
$(".carousel-indicators li").removeClass();
$(".carousel-indicators li").eq(index - 1).addClass("active")
.siblings().removeClass();
}
第二步,实现中间白点点
4000
击变图
$(".carousel-indicators li").click(
function() {
stop = true;
index = $(this).index() + 1;
$(".carousel-indicators li").eq(index - 1).addClass(
"active").siblings().removeClass();
$(".item img").attr("src", "image/img0" + index + ".png")
.show();
});
$(".carousel-inner").hover(function() {
stop = true;
}, function() {
stop = false;
});
第三步,实现悬浮停止,点击变图
var ss = setInterval(xianshi, 1500);
$(".carousel-control").hover(function() {
stop = true;
}, function() {
stop = false;
});
$("[data-slide='prev']").click(function() {
index--;
if (index == 0) {
index = 3;
}
$(".item img").attr("src", "image/img0" + index + ".png").show();
$(".carousel-indicators li").removeClass();
$(".carousel-indicators li").eq(index - 1).addClass("active")
.siblings().removeClass();
});
$("[data-slide='next']").click(function() {
index++;
if (index == 4) {
index = 1;
}
$(".item img").attr("src", "image/img0" + index + ".png").show();
$(".carousel-indicators li").removeClass();
$(".carousel-indicators li").eq(index - 1).addClass("active")
.siblings().removeClass();
});
第一步,实现自动轮播
var index = 0;
var stop = false;
function xianshi() {
if (stop) {
return;
}
if (index < 3) {
index++;
} else {
index = 1;
}
$(".item img").attr("src", "image/img0" + index + ".png").show();
$(".carousel-indicators li").removeClass();
$(".carousel-indicators li").eq(index - 1).addClass("active")
.siblings().removeClass();
}
第二步,实现中间白点点
4000
击变图
$(".carousel-indicators li").click(
function() {
stop = true;
index = $(this).index() + 1;
$(".carousel-indicators li").eq(index - 1).addClass(
"active").siblings().removeClass();
$(".item img").attr("src", "image/img0" + index + ".png")
.show();
});
$(".carousel-inner").hover(function() {
stop = true;
}, function() {
stop = false;
});
第三步,实现悬浮停止,点击变图
var ss = setInterval(xianshi, 1500);
$(".carousel-control").hover(function() {
stop = true;
}, function() {
stop = false;
});
$("[data-slide='prev']").click(function() {
index--;
if (index == 0) {
index = 3;
}
$(".item img").attr("src", "image/img0" + index + ".png").show();
$(".carousel-indicators li").removeClass();
$(".carousel-indicators li").eq(index - 1).addClass("active")
.siblings().removeClass();
});
$("[data-slide='next']").click(function() {
index++;
if (index == 4) {
index = 1;
}
$(".item img").attr("src", "image/img0" + index + ".png").show();
$(".carousel-indicators li").removeClass();
$(".carousel-indicators li").eq(index - 1).addClass("active")
.siblings().removeClass();
});
第一步,实现自动轮播
相关文章推荐
- JSP分页c:foreach分页代码以及效果新闻发布系统
- 一个完整的新闻发布系统(1)
- 牛腩新闻发布系统--学习Web的小技巧汇总
- J2EE项目:整合SSH开发『新闻发布系统』
- 牛腩新闻发布系统-母版页图片不显示问题
- 牛腩新闻发布系统--点击修改类别
- 牛腩新闻发布系统总结
- 新闻发布系统
- 【NodeJS 学习笔记04】新闻发布系统
- 牛腩新闻发布系统-初识总体框架
- 【牛腩新闻发布系统】”验证码显示异常“解决办法
- php新闻发布系统发布成功从数据库查询所有数据用表格显示出来03
- 基于JSP+SERVLET的新闻发布系统(二)
- [转]jQuery实现图片轮播效果,jQuery实现焦点新闻
- 新闻发布系统(首页)
- C#版的网站新闻发布系统
- CSDN支持“雕塑”系统的新闻已经发布!
- 牛腩新闻发布系统——后台登录界面生成验证码
- 牛腩新闻发布系统———如何在开发中使用第三方控件
- 牛腩新闻发布系统之获取IP