初探js特效魅力05
接下来为大家介绍的选项卡的切换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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.οnlοad=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].οnclick=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