javascript简单选项卡,一个页面可多次引用

短命女 2022-08-10 14:40 44阅读 0赞
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>选项卡</title>
  6. <script language="javascript" type="text/javascript">
  7. <!--
  8. function setTab(name,cursel,n){
  9. for(i=1;i<=n;i++){
  10. var menu=document.getElementById(name+i);
  11. var con=document.getElementById("con_"+name+"_"+i);
  12. menu.className=i==cursel?"hover":"";
  13. con.style.display=i==cursel?"block":"none";
  14. }
  15. }
  16. //-->
  17. </script>
  18. <style type="text/css">
  19. *{ margin:0; padding:0;}
  20. li{ list-style:none;}
  21. .main{ width:230px; border:solid 1px #e0e0e0; border-width:1px 1px 1px 0; margin:20px;}
  22. .Menubox{
  23. width:100%;
  24. height:32px;
  25. line-height:32px;
  26. }
  27. .Menubox li{
  28. float:left;
  29. display:block;
  30. cursor:pointer;
  31. width:115px; height:32px;
  32. text-align:center;
  33. border:solid 1px #e0e0e0;
  34. border-width:0 0 1px 0;
  35. background:url(bg_li.gif) no-repeat left #f9f9f9;
  36. }
  37. .Menubox li.hover{
  38. width:115px;
  39. height:33px;
  40. border-bottom:none;
  41. color:#ec1c5f;
  42. font-weight:bold;
  43. background:url(bg_li.gif) no-repeat left #fff;
  44. }
  45. .Contentbox,.Contentbox1{
  46. border-left:solid 1px #e0e0e0;
  47. padding:10px;
  48. clear:both;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <div class="main">
  54. <div class="Menubox">
  55. <ul>
  56. <li id="one1" onMouseOver="setTab('one',1,2)" class="hover">新闻资讯</li>
  57. <li id="one2" onMouseOver="setTab('one',2,2)">最新动态</li>
  58. </ul>
  59. </div>
  60. <div class="Contentbox">
  61. <div class="free_mer1" id="con_one_1" style="display:;">新闻资讯</div>
  62. <div class="free_mer1" id="con_one_2" style="display:none;">最新动态</div>
  63. </div>
  64. </div>
  65. </body>
  66. </html>

用到的图片:bg_li.gif

SouthEast

发表评论

表情:
评论列表 (有 0 条评论,44人围观)

还没有评论,来说两句吧...

相关阅读