<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="../Scripts/jquery-1.7.2.js"></script>
<style type="text/css">
body,div,ul,li,a,img{margin: 0;padding: 0;}
ul,li{list-style: none;}
a{text-decoration: none;} #wrapper{position: relative;margin: 30px auto;width: 400px;height: 200px;}
#banner{position:relative;width: 400px;height: 200px;overflow: hidden;}
.imgList{position:relative;width:2000px;height:200px;z-index: 10;overflow: hidden;}
.imgList li{float:left;display: inline;}
#prev,
#next{position: absolute;top:80px;z-index: 20;cursor: pointer;opacity: 0.2;filter:alpha(opacity=20);}
#prev{left: 10px;}
#next{right: 10px;}
#prev:hover,
#next:hover{opacity: 0.5;filter:alpha(opacity=50);}
.bg{position: absolute;bottom: 0;width: 400px;height: 40px;z-index:20;opacity: 0.4;filter:alpha(opacity=40);background: black;}
.infoList{position: absolute;left: 10px;bottom: 10px;z-index: 30;}
.infoList li{display: none;}
.infoList .infoOn{display: inline;color: white;}
.indexList{position: absolute;right: 10px;bottom: 5px;z-index: 30;}
.indexList li{float: left;margin-right: 5px;padding: 2px 4px;border: 2px solid black;background: grey;cursor: pointer;}
.indexList .indexOn{background: red;font-weight: bold;color: white;}
</style>
</head>
<body>
<div id="wrapper">
<!-- 最外层部分 -->
<div id="banner">
<!-- 轮播部分 -->
<ul class="imgList">
<!-- 图片部分 -->
<li><a href="#"><img src="../images/1.jpg" width="400px" height="200px" alt="puss in boots1"></a></li>
<li><a href="#"><img src="../images/2.jpg" width="400px" height="200px" alt="puss in boots2"></a></li>
<li><a href="#"><img src="../images/3.jpg" width="400px" height="200px" alt="puss in boots3"></a></li>
<li><a href="#"><img src="../images/4.jpg" width="400px" height="200px" alt="puss in boots4"></a></li>
<li><a href="#"><img src="../images/5.jpg" width="400px" height="200px" alt="puss in boots5"></a></li>
</ul>
<img src="../images/qianxleft1.png" width="20px" height="40px" id="prev">
<img src="../images/qianxr1.png" width="20px" height="40px" id="next">
<div class="bg"></div> <!-- 图片底部背景层部分-->
<ul class="infoList">
<!-- 图片左下角文字信息部分 -->
<li class="infoOn">puss in boots1</li>
<li>puss in boots2</li>
<li>puss in boots3</li>
<li>puss in boots4</li>
<li>puss in boots5</li>
</ul>
<ul class="indexList">
<!-- 图片右下角序号部分 -->
<li class="indexOn">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
<script src="../Scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var curIndex = 0,//当前index
imgLen = $(".imgList li").length;//图片总数
var autoChange = setInterval(function () {
if (curIndex < imgLen - 1) {
curIndex++;
} else {
curIndex = 0;
}
changeTo(curIndex);
}, 2500);
//左箭头事件
$("#prev").hover(function () {
clearInterval(autoChange);//滑入定时器清除;
}, function () {
autoChangeAgain();
});
$("#prev").click(function () {
//根据curIndex处理上一张图片
curIndex = (curIndex > 0) ? (--curIndex) : (imgLen - 1);
changeTo(curIndex);
});
//右箭头滑入事件
$("#next").hover(function () {
//滑入清除定时器
clearInterval(autoChange);
}, function () {
autoChangeAgain();
});
//右箭头点击处理事件
$("#next").click(function () {
curIndex = (curIndex < imgLen - 1) ? (++curIndex) : 0;
changeTo(curIndex);
});
//清除定时器时候的重置定时器--封装
function autoChangeAgain() {
autoChange = setInterval(function () {
if (curIndex < imgLen - 1) {
curIndex++;
} else {
curIndex = 0;
}
//调用变换处理函数
changeTo(curIndex);
}, 2500);
}
function changeTo(num) {
var goLeft = num * 400;
$(".imgList").animate({ left: "-" + goLeft + "px" }, 500);
$(".infoList").find("li").removeClass("infoOn").eq(num).addClass("infoOn");
$(".indexList").find("li").removeClass("indexOn").eq(num).addClass("indexOn");
}
//对右下角按钮index进行事件绑定处理等
$(".indexList").find("li").each(function (item) {
$(this).hover(function () {
clearInterval(autoChange);
changeTo(item);
curIndex = item;
}, function () {
autoChangeAgain();
});
});
</script>
</body>

原生JQ实现图片滑动轮播的更多相关文章

  1. 原生js实现图片轮播思路分析

    一.复习原生js实现图片轮播 1.要点 自动轮播 点击小圆圈按钮,显示相应图片 点击左右箭头,实现向前向后轮播图片 2.实现思路 <div id="container"> ...

  2. jq实现图片轮播:圆形焦点+左右控制+自动轮播

    来源:http://www.ido321.com/862.html html代码: 1: <!DOCTYPE html> 2: <html lang="en"&g ...

  3. 原生js实现图片轮播效果

    思路:设置父容器(一定宽度,一定高度,相对定位,子容器超出部分进行隐藏),子容器图片并排(浮动,绝对定位,每次点击进行相应的左或右偏移量) 1.html: <!DOCTYPE html> ...

  4. 原生Js_简易图片轮播模板

    功能:图片自动循环轮播,通过点击“上一张”,“下一张”按钮来控制图片的切换 <!DOCTYPE html> <html> <head> <meta chars ...

  5. 原生Javascript实现图片轮播效果

    首先引入js运动框架 function getStyle(obj,name){ if(obj.currentStyle){ return obj.currentStyle[name]; } else{ ...

  6. 原生JS实现图片轮播

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. JQ简单图片轮播

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. 图片轮播(左右切换)--JS原生和jQuery实现

    图片轮播(左右切换)--js原生和jquery实现 左右切换的做法基本步骤跟 上一篇文章  淡入淡出 类似,只不过修改了一些特定的部分 (1)首先是页面的结构部分 对于我这种左右切换式 1.首先是个外 ...

  9. 图片轮播(淡入淡出)--JS原生和jQuery实现

    图片轮播(淡入淡出)--js原生和jquery实现 图片轮播有很多种方式,这里采用其中的 淡入淡出形式 js原生和jQuery都可以实现,jquery因为封装了很多用法,所以用起来就简单许多,转换成j ...

随机推荐

  1. HW6.10

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HDU-4616 Game 树形DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4616 比较典型的树形DP题目,f[u][j][k]表示以点u为子树,经过 j 个陷阱的最大值,其中k= ...

  3. ubuntu源码安装R语言

    下载后解压完,进入开始配置: ./configure --enable-R-shlib 报错: configure: error: con--with-readline=yes (default) a ...

  4. 总结与学习DIV+CSS网页布局技巧

    以前用表格布局时设置网页居中非常方便,把表格对齐方式设置为居中就行了,就这么简单,现在呢,用DIV+CSS样式表控制,好像不是那么容易了,其实也很简单,只不过方式不同而已. <style> ...

  5. android界面优化笔记(TODO)

    1.避免使用线性布局的层层嵌套,要使用相对而已.使用线性布局越多,嵌套越多 官方文档: Optimizing Your UI

  6. A Tour of Go Web servers

    Package http serves HTTP requests using any value that implementshttp.Handler: package http type Han ...

  7. python 使用模块

    Python本身就内置了很多非常有用的模块,只要安装完毕,这些模块就可以立刻使用. 我们以内建的sys模块为例,编写一个hello的模块: #!/usr/bin/env python # -*- co ...

  8. javaScript 要点(十五)HTML DOM 导航

    通过 HTML DOM,能够使用节点关系在节点树中导航. 1.HTML DOM 节点列表 getElementsByTagName() 方法返回节点列表.节点列表是一个节点数组. 下面的代码选取文档中 ...

  9. JNI函数复杂对象传递

    主要操作内容,包括如下几个部分: 1.在Native层返回一个字符串 2.从Native层返回一个int型二维数组(int a[ ][ ]) 3.从Native层操作Java层的类: 读取/设置类属性 ...

  10. .NET常用工具类集锦

    不错的地址: http://www.cnblogs.com/flashbar/archive/2013/01/23/helper.html https://github.com/chrisyanghu ...