jquery案例3-模仿京东轮播图

发布时间:2022-06-28 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了jquery案例3-模仿京东轮播图脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

1.效果

jquery案例3-模仿京东轮播图

 

 

2.代码展示

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>动画</title>
	<style>
		* {
			margin:0px;
			padding:0px;
		}
		li {
			list-style: none;
			position: absolute;
			display: none;
		}
		li:first-child {
			display: block;
		}
		.slide {
			width: 590px;
			height: 470px;
			position: relative;
			margin:0px auto;
			margin-top:100px;
		}
		.next {
			position: absolute;
			right: -200px;
			top:200px;
		}
		.prev {
			position: absolute;
			left: -200px;
			top:200px;
		}
	</style>
</head>
<script src="jquery.js"></script>
<body>
	<div class="slide">
		<ul>
			<li><img src="./jd/1.jpg" alt=""></li>
			<li><img src="./jd/2.jpg" alt=""></li>
			<li><img src="./jd/3.jpg" alt=""></li>
			<li><img src="./jd/4.jpg" alt=""></li>
			<li><img src="./jd/5.jpg" alt=""></li>
		</ul>
		<input type="button" value="下一张" class="next">
		<input type="button" value="上一张" class="prev">
	</div>
</body>
</html>
<script>
	$(function(){
		var count=0;
		$(".next").click(function(){
			count++;
			console.log(count);
			if(count >= $(".slide li").length){
				count=0;
			}
			$(".slide li").eq(count).fadeIn().siblings().fadeOut();
		});

		$(".prev").click(function(){
			count--;
			if(count <=0 ){
				count = $(".slide li").length-1;
			}
			console.log(count);
			$(".slide li").eq(count).fadeIn().siblings().fadeOut();
		});
	});
</script>

  

脚本宝典总结

以上是脚本宝典为你收集整理的jquery案例3-模仿京东轮播图全部内容,希望文章能够帮你解决jquery案例3-模仿京东轮播图所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: