标签:doctype htm css button charset doc char btn win
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>选项卡</title> <style type="text/css"> input{background: white;} .active{background: yellow;} div{width:200px;height: 100px;background: #ccc;display: none;} </style> <script type="text/javascript"> window.onload=function(){ var aBtn=document.getElementsByTagName(‘input‘); var aDiv=document.getElementsByTagName(‘div‘); var i=0; for (i = 0; i < aBtn.length; i++) { aBtn[i].index=i; aBtn[i].onclick=function(){ for(i=0;i<aBtn.length;i++){ aBtn[i].className=‘‘; aDiv[i].style.display=‘none‘; } // alert(this.index); aDiv[this.index].style.display="block"; this.className=‘active‘; } }; } </script> </head> <body> <input type="button" class="active" value="1" > <input type="button" value="2"> <input type="button" value="3"> <div style="display:block">111</div> <div>222</div> <div>333</div> </body> </html>
标签:doctype htm css button charset doc char btn win
原文地址:http://www.cnblogs.com/Mr-W/p/6290210.html