图片的切换

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>New Web Project</title>
		<style type="text/css">
			#div1{
				width:450px;
				height:250px;
				border:1px solid  #C404DD;
			}
		#i1,#i2,#i2,#i3{
			display: none;
		}	
		#s1{	
			width:13px;
			border: 1px solid red;
			position: absolute;
			left: 390px;
			top: 240px;
			background-color: red;
			color: white;
		}
			#s2{
			width:13px;	
			border: 1px solid red;
			position: absolute;
			left: 407px;
			top: 240px;
			background-color: red;
			color: white;
		}
			#s3{	
			width:13px;
			border: 1px solid red;
			position: absolute;
			left: 424px;
			top: 240px;
			background-color: red;
			color: white;
		}
			#s4{	
			width:13px;
			border: 1px solid red;
			position: absolute;
			left: 441px;
			top: 240px;
			background-color: red;
			color: white;
		}
		</style>
		
		<script type="text/javascript">
			var i=1;
			function doGo(){
				//隐藏所有图片
				for (var j = 1; j<=4; j++){
				  	var strI="i"+j;
				  	var strS="s"+j;			  		
			  	document.getElementById(strI).style.display="none";
			  	document.getElementById(strS).style.backgroundColor="red";
				}
				//改变所有显示的图片序号
				i++;
				if(i>4){
					i=1;
				}	
				var value="i"+i;
				var b="s"+i;
				//显示新的图片
				document.getElementById(b).style.backgroundColor="pink";
				document.getElementById(value).style.display="block";
				var time =window.setTimeout("doGo()",3000);
			}
			function domousedown(i1){
				
			for (var j = 1; j<=4; j++){
				  	var strI="i"+j;
				  	var strS="s"+j;			  
				  	//隐藏所有图片		
			  		document.getElementById(strI).style.display="none";
			  		//所有数字背景色设为红
			  		document.getElementById(strS).style.backgroundColor="red";
				}
				//显示点击的图片
				document.getElementById(i1).style.display="block";
				//改变所点点击的数字背景色
				switch(i1){
					case "i1":i=1;break;
					case "i2":i=2;break;
					case "i3":i=3;break;
					case "i4":i=4;break;
				}
				var b="s"+i;
				//点击的数字的背景色设为粉红
				document.getElementById(b).style.backgroundColor="pink";
			
			}
		</script>
	</head>
	<body οnlοad="doGo()">
		<div id="div1">
			<span id="s1" οnmοusedοwn="domousedown('i1')">1</span>
			<span id="s2" οnmοusedοwn="domousedown('i2')">2</span>
			<span id="s3" οnmοusedοwn="domousedown('i3')">3</span>
			<span id="s4" οnmοusedοwn="domousedown('i4')">4</span>
			<img id="i1" src="i1.jpg" />
			<img id="i2" src="i2.jpg" />
			<img id="i3" src="i3.jpg" />
			<img id="i4" src="i4.jpg" />
			
		</div>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值