zoukankan      html  css  js  c++  java
  • 表格折叠展开

    表格折叠展开其实质就是列的隐藏和显示,用JQuery很容易实现这个。

    折叠展开的效果如下两图

    源码如下

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>表格列显示隐藏</title>
            <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
            <style type="text/css">
                body{ font-size:12px;}
                .iup{ background-color:#eee;}
                #table1{ background-color:#333;}
                #table1 td{ background-color:#fff;}
            </style>

            <script type="text/javascript">
         $(document).ready(function(){
               $("#showbtn").toggle(
                function () {
                    $('.iup').hide();
                    $(this).val('显示');
                },
                function () {
                    $('.iup').show();
                    $(this).val('隐藏');
                }
            );
          })
            
          </script>
        </head>
        <body align='center'>
    <center>
        <input type='button' value='隐藏' id='showbtn' />
        <br/>
                    <table id='table1' cellspacing='1'>
                     <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr>
                      <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr>
                      <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr>
                      <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr>
                      <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr>
                      <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr> <tr>
                     <td width='150'>第一格</td>
                     <td width='250' class='iup'><input type='text'/></td>
                     <td width='150'>第三格</td>
                     </tr>
                   </table>
        
          </center>  
        </body>
    </html>

  • 相关阅读:
    (转)classload和class.forname()区别
    (转)HashMap和HashTable源码
    (转)spring 框架介绍
    [Spring入门学习笔记][创建网站URL]
    [spring入门学习笔记][spring的IoC原理]
    [J2EE学习][post,get乱码处理]
    [J2EE框架][Debug]
    [SQL学习笔记][用exists代替全称量词 ]
    [Spring入门学习笔记][Spring Boot]
    [Spring入门学习笔记][maven]
  • 原文地址:https://www.cnblogs.com/haiconc/p/2353318.html
Copyright © 2011-2022 走看看