JQuery 图片滚动轮播示例代码 - Web前端
作者:98wpeu发布时间:2026-06-25分类:网页前端技术浏览:69
导读:完整的项目在附件中复制代码代码如下:<!DOCtypehtml><HTML><head><title>图片切换</t...
完整的项目在附件中
复制代码 代码如下:
<!DOCtypehtml>
<HTML>
<head>
<title>图片切换</title>
<script type="text/javascript" src="JS/JQuery-1.11.0.min.js"></script>
<script type="text/JavaScript" >
var num = 0
$(function(){
$("div ol li").mouSEOver(function(e){
$(this).attr("class","current");
$(this).siblings().attr("class",""); //兄弟节点的class属性设置为空
//alert($('ul').index())
num = $('ul').index() + 2
var index = $(this).index(); //记录选定的li标签在ul中的索引
//图片会出现层叠现象为了显示当前的图片,把当前的图片的z-index 值设置为大于其他的兄弟元素
$("div ul li").eq(index).CSS({"left":"650px","zIndex":num})
$("div ul li").eq(index).siblings().css("zIndex",num-1);
//动画效果,图片从右侧飞入
$("div ul li").eq(index).Animate({left:"0"},500)
});
});
</script>
<style type="text/css">
*{margin: 0px;padding: 0px;border: 0px;}
ul,ol{list-style: none;}
.all{width:650px;height: 250px;margin: 100px auto;position: relative;border: 1px solid crimson;overflow: hidden;}
.all ul{position: relative;z-index: 1;position: relative;}
/*子 绝 父 相*/
.all ul li{position: absolute;left: 0;top: 0px;}
.all ol{position: absolute;z-index: 2; right: 10px;bottom: 10px;}
.all ol li{width: 20px;height: 20px;background: #333;border: 1px solid #509629;font-weight:
bold;text-align: center;line-height: 20px;float: left;margin-left: 10px;margin-top: 10px;}
.all ol .current{width: 30px;height: 30px;line-height: 30px;border: 1px solid red;margin-top: 0px;
cursor: pointer;}
</style>
</head>
<body>
<div class="all">
<ul>
<li><img src="src/1.jpg" /></li>
<li><img src="src/2.jpg" /></li>
<li><img src="src/3.jpg" /></li>
<li><img src="src/4.jpg" /></li>
</ul>
<ol>
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ol>
</div>
</body>
</html>
复制代码 代码如下:
<!DOCtypehtml>
<HTML>
<head>
<title>图片切换</title>
<script type="text/javascript" src="JS/JQuery-1.11.0.min.js"></script>
<script type="text/JavaScript" >
var num = 0
$(function(){
$("div ol li").mouSEOver(function(e){
$(this).attr("class","current");
$(this).siblings().attr("class",""); //兄弟节点的class属性设置为空
//alert($('ul').index())
num = $('ul').index() + 2
var index = $(this).index(); //记录选定的li标签在ul中的索引
//图片会出现层叠现象为了显示当前的图片,把当前的图片的z-index 值设置为大于其他的兄弟元素
$("div ul li").eq(index).CSS({"left":"650px","zIndex":num})
$("div ul li").eq(index).siblings().css("zIndex",num-1);
//动画效果,图片从右侧飞入
$("div ul li").eq(index).Animate({left:"0"},500)
});
});
</script>
<style type="text/css">
*{margin: 0px;padding: 0px;border: 0px;}
ul,ol{list-style: none;}
.all{width:650px;height: 250px;margin: 100px auto;position: relative;border: 1px solid crimson;overflow: hidden;}
.all ul{position: relative;z-index: 1;position: relative;}
/*子 绝 父 相*/
.all ul li{position: absolute;left: 0;top: 0px;}
.all ol{position: absolute;z-index: 2; right: 10px;bottom: 10px;}
.all ol li{width: 20px;height: 20px;background: #333;border: 1px solid #509629;font-weight:
bold;text-align: center;line-height: 20px;float: left;margin-left: 10px;margin-top: 10px;}
.all ol .current{width: 30px;height: 30px;line-height: 30px;border: 1px solid red;margin-top: 0px;
cursor: pointer;}
</style>
</head>
<body>
<div class="all">
<ul>
<li><img src="src/1.jpg" /></li>
<li><img src="src/2.jpg" /></li>
<li><img src="src/3.jpg" /></li>
<li><img src="src/4.jpg" /></li>
</ul>
<ol>
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ol>
</div>
</body>
</html>
相关推荐
- 20款超赞的jQuery插件 Web开发人员必备 - Web前端
- 从零开始学习jQuery (十) jQueryUI常用功能实战 - Web前端
- 基于jquery的jqDnR拖拽溢出的修改 - Web前端
- 基于JQuery的asp.net树实现代码 - Web前端
- jquery ui dialog ie8出现滚动条的解决方法 - Web前端
- 基于jquery的网页SELECT下拉框美化代码 - Web前端
- 基于jquery的图片幻灯展示源码 - Web前端
- 基于jQuery的实现简单的分页控件 - Web前端
- 自写的一个jQuery圆角插件 - Web前端
- 基于jquery的跟随屏幕滚动代码 - Web前端
- 网页前端技术排行
-
- 1[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 2分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 3【第六章】Foundation之按钮和下拉功能 - Web前端
- 4jQuery编写widget的一些技巧分享 - Web前端
- 5基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 6jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 7在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 8分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 9javascript原生和jquery库实现iframe自适应高度和宽度 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


