继续优化

<!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;
}
.public_scroll {
position: relative;
min-width: 1100px;
max-width: 100%;
height: 793px; overflow: hidden; }
.public_s_list{ overflow: hidden;} .public_s_list a {
position: absolute; display: block;
width: 100%;
} .public_s_list a img {
width: 100%;
display: block; }
.public_s_dot{ overflow: hidden; text-align: center; position: absolute; bottom:25px; z-index: 2; width: 100%; }
.public_s_dot i{ width: 10px; height: 10px; background-color: #fff; margin:0 8px; display: inline-block; cursor: pointer; border-radius: 50%;}
.public_s_dot .active{ background-color: #808080 }
</style>
</head> <body>
<div class="public_scroll" id="publicScroll">
<div class="public_s_list">
<a href="javascript:;" class="J_pic"><img src="http://www.emoi.com/media/pc-cn/201810/1540853894181026841.jpg" alt="1"></a>
<a href="javascript:;" class="J_pic"><img src="http://www.emoi.com/media/pc-cn/201805/1525203825936416255.jpg" alt="2"></a>
<a href="javascript:;" class="J_pic"><img src="http://www.emoi.com/media/pc-cn/201712/1513641621162167882.jpg" alt="3"></a>
</div>
<div class="public_s_dot" id="publicDot"></div>
</div>
<script type="text/javascript">
$(function() {
var index = 0;
var timer;
//获取id为publicScroll 所有的img
var imgList = $('#publicScroll .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(); //鼠标离开继续自动播放
});
// 填充分页
var bPage=$('#publicDot');
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;
}
showBg();
}, 4000);
}
//自动播放图片
showTime();
}
});
</script>
</body> </html>

jquery优化轮播图2的更多相关文章

  1. 用jQuery实现轮播图效果,js中的排他思想

    ---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...

  2. 用js和jQuery做轮播图

    Javascript或jQuery做轮播图 css样式 <style> a{ text-decoration:none; } .naver{ width: 100%; position:r ...

  3. 自实现PC端jQuery版轮播图

    最近其他项目不是很忙,被安排给公司的官网项目做一个新的页面(之前没接触公司官网项目),其中有一个用到轮播图的地方,最开始想直接用swiper.js插件实现就好了,可是发现官网项目里之前都没有引入过sw ...

  4. JQuery实现轮播图及其原理

    源码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" name="vi ...

  5. Jquery无缝轮播图的制作

    轮播是html页面中比较常见的一种展现形式,也是基础,把轮播图做好,是排版中比较关键的 1.首先是轮播的html元素放置:做轮播之前,要有一个初步的认识 2.每个元素的位置怎样摆放,也是很关键的,这里 ...

  6. jquery改造轮播图1

    g改造轮播图1:https://www.cnblogs.com/huanghuali/p/8677338.html <!DOCTYPE html> <html lang=" ...

  7. jQuery无缝轮播图思路详解-唯品会

    效果图如上: 需求:图片自动轮播,鼠标移上停止播放,离开恢复播放,箭头切换图片. html代码 <!--轮播图大盒子开始--> <div class="wrap" ...

  8. jQuery封装轮播图插件

    // 布局要求,必须有一个容器,图片和两个按钮,布局方式自定,小圆点样式固定 // <div class="all"> // <img src="img ...

  9. 自己随意写了个简单的依赖jquery的轮播图

    //轮播图 function Switcher(obj){ this.box = $(obj.box); this.width = this.box.width(); this.banner = $( ...

随机推荐

  1. Ssm框架常见报错

    错误1: The origin server did not find a current representation for the target resource or is not willi ...

  2. kaggle-泰坦尼克号Titanic-1

    大家都熟悉的『Jack and Rose』的故事,豪华游艇倒了,大家都惊恐逃生,可是救生艇的数量有限,无法人人都有,副船长发话了『lady and kid first!』,所以是否获救其实并非随机,而 ...

  3. [转]【流媒體】H264—MP4格式及在MP4文件中提取H264的SPS、PPS及码流

    [流媒體]H264—MP4格式及在MP4文件中提取H264的SPS.PPS及码流 SkySeraph Apr 1st 2012  Email:skyseraph00@163.com 一.MP4格式基本 ...

  4. 前端福利之jQuery文字轮播特效(转)

    闲谈:离开学校那座象牙塔已经也有大半年的事件了,生活中不再充满了茫然只有忙碌.连续加班加点大半个月,做的活动项目终于算是告一段落了,而今天也将是考验其真正价值的时候,现在将这次开发中遇到的问题做一下总 ...

  5. 团体程序设计天梯赛L2-023 图着色问题 2017-04-17 09:28 269人阅读 评论(0) 收藏

    L2-023. 图着色问题 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 图着色问题是一个著名的NP完全问题.给定无向图 G ...

  6. Spring IOC 和 AOP概述

    IoC(控制反转,(Inversion of Control):本来是由应用程序管理的对象之间的依赖关系,现在交给了容器管理,这就叫控制反转,即交给了IoC容器,Spring的IoC容器主要使用DI方 ...

  7. IntentService介绍

    1.IntentService 是什么 一个封装了HandlerThread和Handler的异步框架. 是一种特殊Service,继承自Service,是抽象类,必须创建子类才可以使用. 可用于执行 ...

  8. zabbix监控cpu jumps

    cpu监控图形分为三种 cpu jumps cpu突发 包含 context switches per second 进程线程切换 interrupts per second 每秒的中断次数 cpu ...

  9. 报表导出jxls的使用笔记

    基于poi的jxls工具的使用:1.依赖: <dependency> <groupId>org.jxls</groupId> <artifactId>j ...

  10. 简单配置vps,防ddos攻击

    防人之心不可无. 网上总有些无聊或者有意的人.不多说了.上干货,配置vps apf防小流量ddos攻击. 对于大流量的ddos攻击, 需要机房的硬件防火墙,vps内部可能也扛不住. 1. 安装 DDo ...