jquery实现轮播图效果

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			#oImg{
				 width: 500px;
				 height:300px ;
				 background: url(img/0.jpg) no-repeat;
				 background-size:500px 300px ;
				 position: relative;
				 margin:20px auto ;
			}
			#btn1{
				width: 30px;
				height: 50px;
				position: absolute;
				left: 0px;
				top: 110px;
				background: transparent;
				border: none;
				color: red;
				font-size: 48px;
			}
			#btn2{
				width: 30px;
				height: 50px;
				position: absolute;
				left: 470px;
				top: 110px;
				background: transparent;
				border: none;
				color: red;
				font-size: 48px;
			}
			li{
				list-style:none;
				width:10px ;
				height:10px ;
				background:white;
				border-radius: 50%;
				margin: 8px;
				float: left;
			}
			ul{
				position: absolute;
				top: 230px;
				left: 135px;
			}
			
		</style>
	</head>
	<body>
		<div id="oImg">
			<input type="button"  id="btn1" value="<"/>
			<input type="button"  id="btn2" value=">"/>
			<ul>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
			</ul>
			</div>
	</body>
</html>
<script src="js/myjQuery.js"></script>
<script>
	let i=0;
	$("li").eq(0).css({background:"red"});
	$("#btn2").click(function(){
		if(i<5){
			i++;
		}else{
			i=0;
		}
		$("#oImg").css({background:"url(img/"+i+".jpg) no-repeat",backgroundSize:"500px 300px"});
		$("li").css({background:"white"});
		$("li").eq(i).css({background:"red"});
	})
	$("#btn1").click(function(){
		if(i>0){
			i--;
		}else{
			i=5;
		}
		$("#oImg").css({background:"url(img/"+i+".jpg) no-repeat",backgroundSize:"500px 300px"});
		$("li").css({background:"white"});
		$("li").eq(i).css({background:"red"});
	})
</script>

图片效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值