相当有用的Table Row And Col Fix方法。

JQuery.FixedTable

jQuery.FixedTable is a jQuery plugin to create a fixed header and columns on a HTML table. The idea is from https://www.open2space.com/projects/fixedtable. We have improved it, and fixed some bugs.

Feature

  • Allow horizontal and vertical scroll.
  • Support multiple HTML tables in one page.
  • The number of fixed columns can be customize.
  • The background colors of each row when mouse is over and out can be customized.

Files

Nova DownloadDemo , Download: Source Code

Usage

To make a fixed table, you need to some javascript code and a <table> with the <thead> and <tfoot> in your page, and set the elements' class.

e.g.

    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.fixedtable.js"></script>
    <script type="text/javascript">
    // this "tableDiv" must be the table's class
    $(".tableDiv").each(function() {      
        var Id = $(this).get(0).id;
        var maintbheight = 555;
        var maintbwidth = 911;

        $("#" + Id + " .FixedTables").fixedTable({
            width: maintbwidth,
            height: maintbheight,
            fixedColumns: 1,
            // header style
            classHeader: "fixedHead",
            // footer style        
            classFooter: "fixedFoot",
            // fixed column on the left        
            classColumn: "fixedColumn",
            // the width of fixed column on the left      
            fixedColumnWidth: 150,
            // table's parent div's id           
            outerId: Id,
            // tds' in content area default background color                     
            Contentbackcolor: "#FFFFFF",
            // tds' in content area background color while hover.     
            Contenthovercolor: "#99CCFF", 
            // tds' in fixed column default background color   
            fixedColumnbackcolor:"#187BAF", 
            // tds' in fixed column background color while hover. 
            fixedColumnhovercolor:"#99CCFF"  
        });        
    });
    </script>
    
    <div id="tableDiv_Arrays" class="tableDiv">
        <table id="Open_Text_Arrays" class="FixedTables">
            <thead>
                <tr>
                    <th>
                        Purpose
                    </th>
                    <th>
                        C#
                    </th>
                    <th>
                        Php4
                    <th>
                    <th>
                        Php5
                    </th>
                    <th>
                        ActionScript
                    </th>
                    <th>
                        JavaScript
                    </th>
                    <th>
                        Ruby
                    </th>
                </tr>
            <thead>
            <tbody>
                <tr>
                    <th>
                        data1
                    </th>
                    <th>
                        data2
                    </th>
                    <th>
                        data3
                    <th>
                    <th>
                        data4
                    </th>
                    <th>
                        data5
                    </th>
                    <th>
                        data6
                    </th>
                    <th>
                        data7
                    </th>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <th>
                        Purpose
                    </th>
                    <th>
                        C#
                    </th>
                    <th>
                        Php4
                    <th>
                    <th>
                        Php5
                    </th>
                    <th>
                        ActionScript
                    </th>
                    <th>
                        JavaScript
                    </th>
                    <th>
                        Ruby
                    </th>
                </tr>
            </tfoot>
        </table>
    </div>
    

note: if you do not need the footer, just remove the <tfoot> in your html code.

#include <reg52.h> #define uchar unsigned char #define uint unsigned int // 定义键盘行和列 sbit R0 = P1^0; sbit R1 = P1^1; sbit R2 = P1^2; sbit R3 = P1^3; sbit C0 = P1^4; sbit C1 = P1^5; sbit C2 = P1^6; sbit C3 = P1^7; // 键盘映射表 uchar code key_table[] = { '1', '2', '3', 'A', '4', '5', '6', 'B', '7', '8', '9', 'C', '*', '0', '#', 'D' }; // 延时函数 void delay(uint ms) { uint i, j; for (i = 0; i < ms; i++) for (j = 0; j < 114; j++); } // 键盘扫描函数 uchar key_scan() { uchar row, col, key_value = 0; // 初始化行线为高电平,列线为低电平 P1 = 0x0F; // 检查是否有按键按下 if (P1 != 0x0F) { delay(10); // 消抖 if (P1 != 0x0F) { // 逐行扫描 for (row = 0; row < 4; row++) { P1 = ~(0x01 << row); // 设置当前行线为低电平 col = P1 >> 4; // 读取列线状态 if (col != 0x0F) { // 如果有按键按下 switch (col) { case 0x0E: col = 0; break; // 0000 1110 -> 第0列 case 0x0D: col = 1; break; // 0000 1101 -> 第1列 case 0x0B: col = 2; break; // 0000 1011 -> 第2列 case 0x07: col = 3; break; // 0000 0111 -> 第3列 } key_value = key_table[row * 4 + col]; while (P1 != 0x0F); // 等待按键释放 delay(10); // 消抖 return key_value; } } } } return 0; // 无按键按下 } void main() { uchar key; while (1) { key = key_scan(); if (key != 0) { // 在这里处理按键值,例如通过串口输出或控制其他硬件 // 这里简单地将按键值输出到P2口 P2 = key; } } } 上述程序运行按键无值输出,是什么原因
08-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值