码迷,mamicode.com
首页 > 其他好文 > 详细

实现轮播

时间:2018-04-15 22:49:24      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:set   ora   slow   rip   init   script   ide   city   tran   

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="jquery.js"></script>
<script src="index.js"></script>
<style>
li {
list-style: none;
width: 100%;
transition:width 2s;
height: 200px;
text-align: center;
line-height: 200px;
}
.firstLi {
background-color: red;
}
.secondLi {
background-color: orange;
}
.thirdLi {
background-color: yellow;
}
.fourthLi {
background-color: yellowgreen;
}
.fifthLi {
background-color: skyblue;
}
 
</style>
</head>
<body>
<div>
<ul>
<li class="firstLi ease_in_out">
L
</li>
<li class="secondLi ease_in_out">
D
</li><li class="thirdLi ease_in_out">
T
</li><li class="fourthLi ease_in_out">
O
</li><li class="fifthLi ease_in_out">
U
</li>
</ul>
</div>
<p>
<button id="prevPage">上一页</button>
<button id="nextPage">下一页</button>
</p>
</body>
</html>
 
 

$(function($){
$(‘li:gt(0)‘).hide();// 隐藏除第一个以外的其他l
var lis = $("li");
var i = 0;
var j = lis.length;
$(‘#prevPage‘).on(‘click‘,function() {
// 出现上一张
lis.eq(i).fadeOut(1000,function(){
 
if(i === 0){
i = lis.length;
}
i--;
lis.eq(i).fadeIn(1000);
})
// $(‘#testDiv‘).removeClass(‘easeIn‘);
})

$(‘#nextPage‘).on(‘click‘,function() {
// 出现下一张
lis.eq(i).fadeOut(1000,function(){
i++;
if(i === lis.length){
i=0;
}
lis.eq(i).fadeIn(1000);
// lis.eq(i).addClass(‘easeIn‘).show();
// lis.eq(i).animate({
// opacity: ‘show‘
// }, "slow", "easein");

})

})

})

实现轮播

标签:set   ora   slow   rip   init   script   ide   city   tran   

原文地址:https://www.cnblogs.com/datouxiaoming/p/8849673.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!