一、选项卡
<style type="text/css"> *{margin:0px auto; padding:0px;} #xuanxiangka{ 434px; height:26px;text-align:center; line-height:26px; vertical-align:middle;} .xuanxiang{ 434px; height:230px; display:none;} #a:hover{cursor:pointer;} #gongda{display:block; background-color:#309;} #meiti{background-color:#F03;} </style> </head> <body> <div id="xuanxiangka"> <div id="a" style="80px; height:25px; float:left;background-color:#309" onclick="showa('gongda')">工大要闻</div> <div id="a" style="80px; height:25px; float:left;background-color:#F03;" onclick="showa('meiti')">媒体工大</div> </div> <div id="gongda" class="xuanxiang"></div> <div id="meiti" class="xuanxiang"></div> <script type="text/javascript"> function showa(d) { var div=document.getElementById(d); var xuanxiang=document.getElementsByClassName("xuanxiang"); for(var i=0;i<xuanxiang.length;i++) { xuanxiang[i].style.display="none"; } div.style.display="block"; } </script> </body>
二、进度条
<style type="text/css"> *{ margin:0px auto; padding:0px} #kuang{ 200px; height:40px; border:2px solid #60F;} #jindu{ height:40px; background-color:#F03; float:left} </style> </head> <body> <div id="kuang"> <div id="jindu" style="0px"></div> </div> <script type="text/javascript"> window.setTimeout("jindu()",30); //调一下进度前进1% function jindu() { //获取进度div的宽度 var div = document.getElementById("jindu"); //获取到的是字符串"0px" var str = div.style.width; //处理字符串获取数字 var cd = str.substr(0,str.length-2); //判断长度是否到最大值 if(cd<200) { //将长度转为整数加2 var cd = parseInt(cd)+2; //让进度的DIV长度变为cd div.style.width = cd+"px"; //调用自身 window.setTimeout("jindu()",30); } } </script> </body>