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 = $( ...
随机推荐
- "sc.exe create/delete" - Create or Delete Services
"sc.exe" can also be used to create and delete services. If you want to create a new servi ...
- ATL控件签名之后页面还提示“在此页面上的Activex控件和本页上的其他部分及交互可能不安全”
ATL控件正常签名打包,然后安装之后还是会提示: 没理由啊,签名是花钱搞得正当的签名.后来查了资料才知道这还不够,需要在创建ATL控件的时候继承一个IObjectSafetyImpl 类 知道了原因, ...
- Win7+Ubuntu12.04(EasyBCD硬盘安装)
安装双系统 Windows7 + Ubuntu12.04 软件准备 准备两个东西EasyBCD软件和iso镜像(我用的easybcd是2.2版,就下载1.7之后版就行,要那种安装版的,不要绿色版) E ...
- 49. Group Anagrams (string, HashTable)
Given an array of strings, group anagrams together. For example, given: ["eat", "tea& ...
- java文档打包成压缩包并且下载
需求,根据产品ID查询产品详情,产品详情会返回产品的一些文案,以及图片的url.需要做成,将文案信息记录在一个txt文档中,然后图片下载到文件夹,最后下载到本地,下载后自动删除刚才生成的文件夹以及文件 ...
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了 ERROR 2002 ( ...
- Linux主流发行版本
一.简介 而工欲善其事,必先利其器,Linux的世界相當廣大,除了最著名的Ubuntu以外還有不少發行版.然文人相輕,自古皆然,了解不同發行版的優勢不只嘴上攻防用的上,也是學Linux一個有趣的地方! ...
- Python爬虫进阶五之多线程的用法
前言 我们之前写的爬虫都是单个线程的?这怎么够?一旦一个地方卡到不动了,那不就永远等待下去了?为此我们可以使用多线程或者多进程来处理. 首先声明一点! 多线程和多进程是不一样的!一个是 thread ...
- Chrome 强制刷新缓存的方法
https://jingyan.baidu.com/article/11c17a2c2a9e27f446e39d98.html
- Zookeeper 源码(四)Zookeeper 服务端源码
Zookeeper 源码(四)Zookeeper 服务端源码 Zookeeper 服务端的启动入口为 QuorumPeerMain public static void main(String[] a ...