jquery简单轮播图实现
来源:互联网 发布:highcharts.js api 编辑:程序博客网 时间:2024/06/05 10:27
其实轮播的代码很简单只需要20多行jq代码就可以实现了
以下便是简单轮播的代码:
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <script src="js/jquery-3.1.1.js" type="text/javascript" charset="utf-8"></script> <style type="text/css"> *{ padding: 0; margin: 0; } </style> <style type="text/css">#banner { position:relative; width:1048px; height:588px; overflow:hidden;}#banner_list img { border:0px; }#banner_bg { position:absolute; bottom:0; background-color:#000; height:30px;filter: Alpha(Opacity=30); opacity:0.3;z-index:1000; cursor:pointer; width:478px;}#banner_info{ position:absolute; bottom:0; left:5px; height:22px; color:#fff; z-index:1001; cursor:pointer}#banner_text { position:absolute; width:120px; z-index:1002; right:3px; bottom:3px; }#banner ul { position:absolute; list-style-type:none; filter: Alpha(Opacity=80); opacity:0.8; border:1px solid #fff; z-index:1002; margin:0; padding:0; bottom:3px; right:5px; }#banner ul li { padding:0px 8px; float:left; display:block; color:#FFF; border:#e5eaff 1px solid; background:#6f4f67; cursor:pointer; }#banner ul li.on { background:#900; }#banner_list a{ position:absolute; } <!-- 让四张图片都可以重叠在一起--></style> <script type="text/javascript"> var t=0; var y=12,n=0; $(function(){ /*定时器,每隔两秒跳转一个图片*/ t = setInterval("showAuto()", 2000); $("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 2000);});/*悬浮在图片上时,停止跳转*/ $("#banner li").click(function(){/*点击某个li 跳转到相应的图片*/ n=$(this).text()-1; console.log(n); showAuto(); }); }); function showAuto(){ if(y<15){ y=12+n; var i=$(".top li").eq(n).css({background:'red',color:'#FFF'},); $(".top li").filter(':not(:eq('+n+'))').css({background:'#6f4f67',color:'#FFF'});/*进行图片的过滤,并附上css属性*/ console.log(i); n++; console.log(n); }else{ y=12; n=0; } $("#img").attr('src','img/p'+y+'.jpg');/*加载图片*/ } </script> <body> <div class="main"> <div class="top"> <div id="banner"> <ul> <li class="on">1</li> <li>2</li> <li>3</li> <li>4</li> </ul> <div id="banner_list"> <a href="#"><img src="img/p15.jpg" id="img"/></a> </div> </div> </div> </div> </body></html>
效果图如下
阅读全文
0 0
- jquery简单轮播图实现
- jQuery二行简单实现轮播图
- JQuery实现简单菜单
- JQuery 实现简单过滤器
- jquery拖动简单实现
- 简单jQuery插件实现
- Jquery实现简单遮罩层
- jQuery 简单实现
- 利用JQuery实现简单AJAX
- jquery实现简单文字提示
- 实现简单的jquery框架
- 简单瀑布流-jquery实现
- Jquery简单实现图书导航
- jQuery实现简单登陆判断
- jquery实现人物简单走动
- jquery幻灯片简单实现方法
- jquery 实现简单快乐农场
- jQuery实现简单选项卡
- spring-scheduler-job分布式任务调度
- Linux Centos6.8 安装配置Mysql-5.7 yum 安装方式
- c基础_day01
- 设计模式之工厂设计模式(二)
- smartGit过期解决方案
- jquery简单轮播图实现
- POJ Checking an Alibi
- 17.Spark第1部分
- Python:numpy中arange的使用方法
- hdu6152 Friend-Graph CCPC网赛1003 Ramsey定理
- c++实现LogisticRegression/用c++实现逻辑回归
- POJ 3321 树状数组+DFS
- 大家好!刚开通博客,和大家打个招呼,\(^o^)/
- ubuntu eigen 安装与使用