<! DOCTYPE html>
<meta charset= "UTF-8" >
<script src= "Http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js" ></script>
<title>js functions </title>
<body>
<style>
#div0 div{
width:100px;
background:red;
height:100px;
border:1px solid #b2b2b2;
margin-bottom:10px;
Display:none;
}
. active{
Background:yellow;
}
</style>
<div id= "Div0" >
<input type= "button" value= "News" class= "active" >
<input type= "button" value= "Music" >
<input type= "button" value= "Game" >
<input type= "button" value= "Ads" >
<div style= "display:block;margin-top:10px;" > News </div>
<div> Music </div>
<div> Games </div>
<div> Advertising </div>
</div>
<script>
var Div0=document.getelementbyid (' Div0 ')
var ainput=div0.getelementsbytagname (' input ');
var adiv1=div0.getelementsbytagname (' div ');
for (Var i=0;i<ainput.length;i++) {
Ainput[i].index=i
Ainput[i].onclick=function () {
for (Var j=0;j<ainput.length;j++) {
Ainput[j].classname= ";
Adiv1[j].style.display= ' None ';
}
This.classname= ' Active '
Adiv1[this.index].style.display= ' Block '
}
}
</script>
</body>
Native JS tab (code temporary storage)