zoukankan      html  css  js  c++  java
  • jquery案例3模仿京东轮播图

    1.效果

    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 {
    			 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>
    

      

  • 相关阅读:
    搭建yum本地仓库
    VMware中安装Windows_Server_2008_R2
    2020.03.21 JOI春令营&A组 总结
    2020.03.18【NOIP提高组】模拟A 组 总结
    2020.03.14【NOIP提高组】模拟A 组 总结
    2020NOI在线能力测试【入门组】跑步
    价值备注
    Dockers 学习
    给网站配置免费的HTTS证书
    熟悉pyspider的装饰器
  • 原文地址:https://www.cnblogs.com/zh718594493/p/15659550.html
Copyright © 2011-2022 走看看