jquery改造轮播图1
g改造轮播图1:https://www.cnblogs.com/huanghuali/p/8677338.html
<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<title>轮播图</title>
<!-- <link rel="stylesheet" type="text/css" href="css/style.css"> -->
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<!-- <script type="text/javascript" src="js/lunbo.js"></script> -->
<style type="text/css">
*{
margin: 0;
padding: 0;
} body {
font-size: 14px;
line-height: 1.5;
font-family: 'Microsoft Yahei', 'arial', 'tahoma', 'simsun';
color: #666;
background-color: #fff
} img {
border: 0;
} a {
text-decoration: none;
color: #666;
} .wrapper_lb {
position: relative;
width: 640px;
height: 480px;
} .lb_pic_list a {
position: absolute; display: block;
} .lb_pic_list a img {
width: 640px;
height: 480px;
display: block;
} .arrow_left {
position: absolute;
top: 50%;
margin-top: -18px;
left: 10px;
background: red;
width: 80px; height: 30px;
color: #fff;
} .arrow_right {
position: absolute;
top: 50%;
margin-top: -18px;
right: 10px;
background: red;
width: 80px; height: 30px;
color: #fff;
}
.scoll_dot{ overflow: hidden; text-align: center; position: absolute; bottom:0; z-index: 9; }
.scoll_dot i{ width: 16px; height: 6px; background: blue; margin:0 3px; display: inline-block; cursor: pointer;}
.scoll_dot .active{ background-color: red }
</style>
</head> <body>
<div class="wrapper_lb">
<div class="lb_pic_list" id="scrollWrap">
<a href="javascript:;" class="J_pic"><img src="https://img.d1xz.net/d/2018/12/5c10a30eb359a.jpg" alt="1"></a>
<a href="javascript:;" class="J_pic"><img src="https://img.d1xz.net/d/2018/12/5c10a2bd253bd.jpg" alt="2"></a>
<a href="javascript:;" class="J_pic"><img src="https://img.d1xz.net/d/2018/12/5c10a321a708b.jpg" alt="3"></a>
</div>
<div class="scoll_dot J_bannerPage"></div>
<div class="arrow_left J_arrow">向左</div>
<div class="arrow_right J_arrow">向右</div>
</div>
<script type="text/javascript">
$(function() {
var index = 0;
var timer;
//获取id为scrollWrap 所有的img
var imgList = $('#scrollWrap .J_pic');
//img的个数
var imgNum = imgList.length;
if(imgNum>1){
//第一张图显示
$('.J_pic').eq(0).show().siblings().hide(); $('.J_pic').mouseover(function(){
clearInterval(timer); //鼠标经过停止自动播放
});
$('.J_pic').mouseout(function(){
showTime(); //鼠标离开继续自动播放
});
//点击向左按钮
$('.arrow_left').click(function() {
clearInterval(timer);
if (index == 0) {
index = imgNum;
} index--;
showBg();
showTime();
}); //点击向右按钮
$('.arrow_right').click(function() {
clearInterval(timer);
if (index == imgNum - 1) {
index = -1;
} index++;
showBg();
showTime();
});
// 填充分页
var bPage=$(".wrapper_lb").find('.J_bannerPage');
var html='';
for(var i=0,max=imgNum;i<max;i++){
html+=(i==0)?'<i class="active"></i>':'<i></i>';
}
bPage.append(html);
// //鼠标点击分页
bPage.children('i').on('click',function(){ index=$(this).index();
showBg();
}) function showBg() {
$('.J_pic').eq(index).fadeIn(300).siblings().fadeOut(300);
bPage.children('i').eq(index).addClass('active').siblings().removeClass('active');
} function showTime() {
timer = setInterval(function() {
index++;
// if (index == imgNum) {
// index = 0;
// }
index=(index==imgNum)?0:index;
showBg();
}, 2000);
}
//自动播放图片
showTime();
}
});
</script>
</body> </html>
jquery改造轮播图1的更多相关文章
- 用jQuery实现轮播图效果,js中的排他思想
---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...
- 用js和jQuery做轮播图
Javascript或jQuery做轮播图 css样式 <style> a{ text-decoration:none; } .naver{ width: 100%; position:r ...
- 自实现PC端jQuery版轮播图
最近其他项目不是很忙,被安排给公司的官网项目做一个新的页面(之前没接触公司官网项目),其中有一个用到轮播图的地方,最开始想直接用swiper.js插件实现就好了,可是发现官网项目里之前都没有引入过sw ...
- JQuery实现轮播图及其原理
源码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" name="vi ...
- Jquery无缝轮播图的制作
轮播是html页面中比较常见的一种展现形式,也是基础,把轮播图做好,是排版中比较关键的 1.首先是轮播的html元素放置:做轮播之前,要有一个初步的认识 2.每个元素的位置怎样摆放,也是很关键的,这里 ...
- jquery优化轮播图2
继续优化 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- jQuery无缝轮播图思路详解-唯品会
效果图如上: 需求:图片自动轮播,鼠标移上停止播放,离开恢复播放,箭头切换图片. html代码 <!--轮播图大盒子开始--> <div class="wrap" ...
- jQuery封装轮播图插件
// 布局要求,必须有一个容器,图片和两个按钮,布局方式自定,小圆点样式固定 // <div class="all"> // <img src="img ...
- 自己随意写了个简单的依赖jquery的轮播图
//轮播图 function Switcher(obj){ this.box = $(obj.box); this.width = this.box.width(); this.banner = $( ...
随机推荐
- vb.net 与 c# 运算符区别
vb.net vs c# 详细的Operators运算符区别 vb.net ===================== Comparison = < > <= >= <& ...
- java.util.ConcurrentModificationException异常分析
Java在操作ArrayList.HashMap.TreeMap等容器类时,遇到了java.util.ConcurrentModificationException异常.以ArrayList为例,如下 ...
- iOS开源项目:AFNetworking----写得非常好
https://github.com/AFNetworking/AFNetworking 与asi-http-request功能类似的网络库,不过是基于NSURLConnection 和 NSOper ...
- 解决no-session延迟加载问题
解决no-session延迟加载问题 说明:dao层使用Hibernate从数据库查询数据信息返回给web层,在web层打印信息报no-Session错误, 产生原因 关联对象默认都是采用延迟加载 事 ...
- 使用Visual Studio进行 Android开发的十大理由
[原文发表地址]Top 10 reasons to use Visual Studio for C++ Android Development! Visual Studio: C++跨平台的移动解决方 ...
- Glow Shader
[Glow Shader] Glow Shader基于BlurShader来实现.总的来说分为2步: 1.利用BlurShader渲染出BlurTexture. 2.将BlurTexture与SrcT ...
- Rigidbody中 Angular Drag (角阻力):
Rigidbody中 Angular Drag (角阻力):同样指的是空气阻力,只不过是用来阻碍物体旋转的.如果设置成无限的话,物体会立即停止旋转.如果设置成0,物体在上升过程中,会发生侧翻旋转. ...
- Django基础学习七之如何配置django+mysql
很久没有更新博客了,也有段时间没有持续性的学习了,感觉堕落了,今天继续开始学习吧 今天主要来学习一下在django下配置mysql的数据库和使用admin用户管理数据库 1.在project中的set ...
- mybatis sql语句等日志打印
加settings <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configuration ...
- 解决virtualbox共享文件夹没有访问权限的问题
Virtualbox是一款免费试用的虚拟机软件.基本功能完全可替代需要购买或crack的VMware. 在Windows主机上用Virtualbox搭建Linux虚拟机,虚拟机和主机之间传递文件最方便 ...