zoukankan      html  css  js  c++  java
  • td.moveRow方法

    语法:
    oRow = object . moveRow ( iSource , iTarget )
    参数:
    iSource :  必选项。整数值(Integer)。指定被移动的行(Row)在 rows 集合内的序号。默认值是 -1 。
    iTarget :  可选项。整数值(Integer)。指定移动的目标位置在 rows 集合内的序号。默认值是 -1 。

    返回值:
    oRow :  对象(Element)。返回被移动的行(Row)的引用。

    说明:
    移动表格内的行(Row)到新位置。
    在 rows 集合内 iSource 与 iTarget 之间跨越的行数是依据行(Row)移动的方向而变化的。

    <script>
    function rdl_fnMove(){
    oTable.moveRow(1,2);
    }
    </script>


    <table id="oTable">
    <tr><td>第1行第1个单元格</td><td>第1行第2个单元格</td></tr>
    <tr><td style="background:#99CC66;">第2行第1个单元格</td><td style="background:#99CC66;">第2行第2个单元格</td></tr>
    <tr><td style="background:#CC6699;">第3行第1个单元格</td><td style="background:#CC6699;">第3行第2个单元格</td></tr>
    <tr><td>第4行第1个单元格</td><td>第4行第2个单元格</td></tr>
    </table>
    <br><input type="button" value=" 移动 " onclick="rdl_fnMove();">

    =====================================================================================

      将当前行与其上一行对调:

      <table>

        <tr>

          <td onclick="javascript: move_up(this)">上移</td>

          <td onclick="javascript: move_down(this)">下移</td>

        </tr>

        <tr>

          <td onclick="javascript: move_up(this)">上移</td>

          <td onclick="javascript: move_down(this)">下移</td>

        </tr>

         <tr>

          <td onclick="javascript: move_up(this)">上移</td>

          <td onclick="javascript: move_down(this)">下移</td>

        </tr>

        <tr>

          <td onclick="javascript: move_up(this)">上移</td>

          <td onclick="javascript: move_down(this)">下移</td>

        </tr>

      </table>

      <script language="javascript">

        //上移一行

        function move_up(td){   
          var tr = td.parentNode; 

          if(tr.rowIndex!=1)
                tr.parentNode.moveRow(tr.rowIndex,tr.rowIndex-1) ;  
        }   

        //下移一行
        function move_down(td){  
          var tr = td.parentNode;

          if(tr.rowIndex!=tr.parentNode.rows.length-1)   
                tr.parentNode.moveRow(tr.rowIndex, tr.rowIndex + 1);   
        }

      </script>

    =======================================================================

      获取当前行的上一行及下一行

      <table>

        <tr>

          <td onclick="javascript: get_up(this)">获取上一行</td>

          <td onclick="javascript: get_down(this)">获取下一行</td>

        </tr>

        <tr>

          <td onclick="javascript: get_up(this)">获取上一行</td>

          <td onclick="javascript: get_down(this)">获取下一行</td>

        </tr>

         <tr>

          <td onclick="javascript: get_up(this)">获取上一行</td>

          <td onclick="javascript: get_down(this)">获取下一行</td>

        </tr>

        <tr>

          <td onclick="javascript: get_up(this)">获取上一行</td>

          <td onclick="javascript: get_down(this)">获取下一行</td>

        </tr>

      </table>

      <script language="javascript">

        //上移一行

        function get_up(td){   
          var tr = td.parentNode; 

          if(tr.rowIndex != 1)
                var pre_tr = tr.parentNode.rows[tr.rowIndex - 1];

            alert(pre_tr.rowIndex)

        }   

        //下移一行
        function get_down(td){  
          var tr = td.parentNode;

          if(tr.rowIndex != tr.parentNode.rows.length-1)   
                var pre_tr = tr.parentNode.rows[tr.rowIndex + 1];

            alert(pre_tr.rowIndex);

        }

      </script>

  • 相关阅读:
    在.net中过滤敏感字符
    const和readonly的联系和区别
    新闻内容页分页的简单做法
    jmail邮件发送问题
    nvarchar与varchar的区别
    C#中"is" vs "as"
    在C#中,string 类型可与SQL SERVER中的int 类型作比较
    做网站常用代码集锦 (转)
    做网站常用代码集锦 (转)
    ADO 数据类型转换表 oledbtype sqldbtype (二)
  • 原文地址:https://www.cnblogs.com/pricks/p/1641969.html
Copyright © 2011-2022 走看看