| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 479 人关注过本帖
标题:能否简化一下这个js。
只看楼主 加入收藏
mmfeel
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-12-9
收藏
 问题点数:0 回复次数:2 
能否简化一下这个js。
下面的js能否合成一个?

程序代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>

 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <style>
  body {  
     font-family: "Verdana","宋体";
     font-size:12px;
    margin:0;
    padding:0;
}
a,a:visited {
    color:#666666;
    text-decoration:none;
}
a:hover{
    color:#ff0000;
    text-decoration:none;
}
ul, li{
    color:#999999;
    line-height:20px;
}
ol{ margin-top:6px;
    margin-left:16px;
    padding:0;
    list-style-type:none;
    color:#666666;
    }
table, td ,th{
    margin:0;
    padding: 0;
    border:0;
    font-size:12px;
}
img{     border:0;
    padding:0;
    margin:0;
}
.date{
         float:right;
         margin-right:12px;
}
#struct{
          margin:auto;
          width:1000px;
}
  #left_bg{
    background:url(../img/left_bg.jpg) #f4f4f4 repeat-x top left; }
.litop{ margin-top:10px;}
.view{ background:url(../img/view_bg1.jpg) no-repeat; padding-top:18px; padding-left:2px;}
.viewfont a{ color:#0b0b0b; font-size:11px; font-weight:bold;line-height:20px;}
.viewfont a:visited{ color:#0b0b0b; }
.viewfont a:hover{ color:#ff0000; }
.kuang_white{ border:1px #fff solid; background-color:#FFFFFF;}    
</style>

 </HEAD>

 <BODY>
   <table cellSpacing=0 cellPadding=0 align=center border=0 >
    <tr>
      <td class=left_bg vAlign=top width="24%">
        <table cellSpacing=0 cellPadding=0 width="100%" border=0>
          <tr>
            <td class=bt onmouseover="this.className='bt_mouseover'" onclick=this.blur(); onmouseout="this.className='bt_mouseout'"><A href="#" onclick="showLayer(); return false;">报表下载、上报</A> </td>
          </tr>
          <tr>
            <td vAlign=top>
               <div class="zibt" id="aa" style="display:none">
                   <UL>
                       <LI><A href="#">隐患月报</A></LI>
                       <LI><A href="#">检查报表</A></LI>
                       <LI><A href="#">事故报表</A></LI></UL>
                </div>
            </td>
          </tr>
          <tr>
            <td height=4></td>
          </tr>
          <tr>
            <td class=bt onmouseover="this.className='bt_mouseover'" onclick=this.blur(); onmouseout="this.className='bt_mouseout'"><A href="#">组织台帐</A></td>
          </tr>
          <tr>
            <td height=4></td>
          </tr>
                    <tr>
            <td class=bt onmouseover="this.className='bt_mouseover'" onclick=this.blur(); onmouseout="this.className='bt_mouseout'"><A href="#" onclick="showLayer2(); return false;">工作计划</A> </td>
          </tr>
          <tr>
            <td vAlign=top>
                   <div class="zibt" id="bb" style="display:none">
                        <UL>
                            <LI><A href="#">年工作计划</A></LI>
                            <LI><A href="#">月工作计划</A></LI>
                        </UL>
                   </div>
            </td>
          </tr>
    </table>
    <script type="text/javascript">
    var $ = function(id){return document.getElementById(id)}
    function showLayer()
    {
        if($("aa").style.display == "none")
        {
            $("aa").style.display = "block"
        }
        else
        {
            $("aa").style.display = "none"
        }
    }
    </script>
        <script type="text/javascript">
    var $ = function(id){return document.getElementById(id)}
    function showLayer2()
    {
        if($("bb").style.display == "none")
        {
            $("bb").style.display = "block"
        }
        else
        {
            $("bb").style.display = "none"
        }
    }
    </script>

 </BODY>
</HTML>
搜索更多相关主题的帖子: PUBLIC color style 
2010-05-12 08:32
zzqgs1102
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-5-12
收藏
得分:0 
程序代码:
    <script type="text/javascript">
    function showLayer(a)
    {   var $ = function(id){return document.getElementById(id)}
        $(a).style.display == "none"?$(a).style.display = "block":$(a).style.display == "none";
    }
    </script>
2010-05-12 14:20
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:0 
function showLayer(a)
    {   var $ = function(id){return document.getElementById(id)}
        var zt=$(a).style.display;
        $(a).style.display=(zt=="none")?"block":"none";
    }
    </script>
这样才能起作用,赋值是在问号以前,而不是以后!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-05-13 14:43
快速回复:能否简化一下这个js。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020631 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved