超简单的javascript


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>

    <script language="javascript" type="text/javascript">
      lastDiv   =   'Basic'; 
    
     function   ShowDiv(id){          
          current   =   id; 
          if(lastDiv   &&   lastDiv   !=   current)  
                    document.getElementById(lastDiv).style.display   =   'none';  
          document.getElementById(current).style.display   =   'block';  
          lastDiv   =   current;  
 
    }

    </script>

</head>
<body>
        <div>
            <table>
                <tr>
                    <td onclick="ShowDiv('Basic')">
                        1</td>
                    <td onclick="ShowDiv('bbb')">
                        2</td>
                    <td onclick="ShowDiv('ccc')">
                        3</td>
                    <td onclick="ShowDiv('ddd')">
                        4</td>
                </tr>
            </table>
           
            <div id="Basic" >11111111111111111111111</div>
            <div id="bbb"  style="display:none;">22222222222222222222222</div>
            <div id="ccc" style="display:none;">33333333333333333333333</div>
            <div id="ddd" style="display:none;">44444444444444444444444</div>
        </div>
</body>
</html>

 

posted on 2010-06-11 20:20  senly  阅读(337)  评论(0编辑  收藏  举报

导航