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

      

  • 相关阅读:
    mysql安装与基本管理,mysql密码破解
    非阻塞IO模板
    多路复用IO模板
    第四模块:网络编程进阶&数据库开发 练习
    理解Queue队列中join()与task_done()的关系
    第四模块:网络编程进阶&数据库开发 口述
    SQLite
    rest_cherrypy
    SaltStack Returners
    kafka集群安装,配置
  • 原文地址:https://www.cnblogs.com/zh718594493/p/15659550.html
Copyright © 2020-2023  润新知