初探js特效魅力05
<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js特效</title>
<!-- <link id="link1" rel="stylesheet" type="text/css" href="css1.css" />-->
<style>
#div1 .active{
background:pink;
}
#div1 div{
width:200px;
height:200px;
border:1px solid black;
background:pink;
display:none;
}
</style>
<script>
window.onload=function(){
var div1=document.getElementById("div1");
var oBtn=div1.getElementsByTagName("input");
var oDiv=div1.getElementsByTagName("div");
for(var i=0;i<oBtn.length;i++){
oBtn[i].index=i;
oBtn[i].onclick=function(){
for(var i=0;i<oBtn.length;i++){
oBtn[i].className='';
oDiv[i].style.display='none';
}
this.className='active';
oDiv[this.index].style.display="block";
}
}
}
</script>
</head>
<body>
<div id="div1">
<input type="button" class='active' value="教育" id="btn1"/>
<input type="button" value="培訓" id="btn2"/>
<input type="button" value="出國" id="btn3"/>
<input type="button" value="其他" id="btn3"/>
<div style="display:block">111</div>
<div>222</div>
<div>333</div>
<div>4444</div>
</div>
</body>
</html>
未完待續,請繼續收看初探js特效魅力06