感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文档标题</title>
</head>
<body>
<input type="button" class="active" value="1"/>
<input type="button" value="2"/>
<input type="button" value="3"/>
<input type="button" value="4"/>
<div class="div2" style="display:block;">11</div>
<div class="div2">22</div>
<div class="div2">33</div>
<div class="div2">44</div>
</body>
</html>
xxxxxxxxxx
window.onload=function(){
var divs=document.getElementsByTagName("div");
var btns=document.getElementsByTagName("input");
for(var i=0;i<btns.length;i++)
{
btns[i].index=i;
btns[i].onclick=function(){
//清空所有按钮的显示
divs[i].style.display="none";
}
divs[this.index].style.display="block";
.active
background:#9CC;
div
width:300px;
height:200px;
border:1px #666666 solid;
display:none;