Blogger Information
Blog 9
fans 0
comment 0
visits 6556
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
3.27 js轮播图
师太的小迷弟的博客
Original
692 people have browsed it

总结:

function 函数名称(参数){

        var声明一个变量=document.getElementById()在文档中找括号中的id

        var声明一个变量=a.document.getElementByTabName()在变量a中找a标签

        for(i=0;i<a_a.length;//i小于变量a_a的长度;i++){

            a_a[i].style.display="none"//把变量a_a里面的a隐藏

}

    a_a[参数].style.display=“block”"//把变量a_a里面的a显示

}

实例

<!DOCTYPE html>
<html>
<head>
	<title>123</title>
	<meta charset="utf-8">
	<link rel="icon" type="image/x-icon" href="static/images/favicon.ico">
	<style type="text/css">
		div{height: 300px;width: 500px;position: relative;margin:50px auto;overflow: hidden;}
		img{height: 300px;width: 500px; }
		p{display:inline-block;width: 500px;height: 30px;position: absolute;bottom:0;color: #fff;text-align: center;margin: 20px auto;}
		p span{display:inline-block;width: 20px;height: 20px;border:20px;background: rgba(254,254,254,0.6);border-radius: 50%;line-height: 20px;text-align:center;cursor:pointer;}
	</style>
</head>
<body>
	<div id="banner">
		<a href=""><img src="static/images/1.jpg"></a>
		<a href=""><img src="static/images/2.jpg"></a>
		<a href=""><img src="static/images/3.jpg"></a>
		<a href=""><img src="static/images/4.jpg"></a>
		<a href=""><img src="static/images/5.jpg"></a>
		<p>
			<span onclick="ban(0)">1</span>
			<span onclick="ban(1)">2</span>
			<span onclick="ban(2)">3</span>
			<span onclick="ban(3)">4</span>
			<span onclick="ban(4)">5</span>
		</p>
		<script type="text/javascript">
			function ban(ner){
				var a=document.getElementById('banner');
				var a_a=a.getElementsByTagName('a');
				for(var i=0;i<a_a.length;i++){
					a_a[i].style.display="none";
				}
				a_a[ner].style.display="block"
			}
		</script>
	</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post