标签:script name black this onload 选项卡 border his active
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
#vv div{width: 300px;height: 300px;border: 1px solid black;display: none;}
.active{background: red}
</style>
</head>
<body>
<div id="vv">
<input class="active" type="button" value=‘1‘>
<input type="button" value=‘2‘>
<input type="button" value=‘3‘>
<div style="display: block">11111</div>
<div>22222</div>
<div>33333</div>
</div>
<script type="text/javascript">
window.onload=function(){
var aa=new Shuqian();
aa.init();
}
function Shuqian(){
this.oparent=document.getElementById("vv");
this.oinput=this.oparent.getElementsByTagName("input");
this.odiv=this.oparent.getElementsByTagName("div");
}
Shuqian.prototype.init=function(){
var This=this;
for(var i=0;i<this.oinput.length;i++){
this.oinput[i].index=i;
this.oinput[i].onclick=function(){
This.change(this);
}
}
}
Shuqian.prototype.change=function(obj){
for(var i=0;i<this.oinput.length;i++){
this.oinput[i].className="";
this.odiv[i].style.display="none";
}
obj.className="active";
this.odiv[obj.index].style.display="block";
}
</script>
</body>
</html>
标签:script name black this onload 选项卡 border his active
原文地址:http://www.cnblogs.com/liuhao-web/p/6394804.html