• TR move up && TR move down


    code display ::

    <!DOCTYPE HTML>
    <html>
        <head>
            
        <link href="bootstrap.css" rel="stylesheet">
        </head>
        <body>
             <div class="table-responsive">
                <table class="table table-striped">
                  <thead>
                    <tr>
                      <th>#</th>
                      <th>Header</th>
                      <th>Header</th>
                      <th>Header</th>
                      <th>Header</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td>1,000</td>
                      <td>Lorem</td>
                      <td>ipsum</td>
                      <td class="shangyi">dolor</td>
                      <td class="xiayi">sit</td>
                    </tr>
                    <tr>
                      <td>1,001</td>
                      <td>amet</td>
                      <td>consectetur</td>
                      <td class="shangyi">adipiscing</td>
                      <td class="xiayi">elit</td>
                    </tr>
                    <tr>
                      <td>1,002</td>
                      <td>Integer</td>
                      <td>nec</td>
                      <td class="shangyi">odio</td>
                      <td class="xiayi">Praesent</td>
                    </tr>
                    <tr>
                      <td>1,003</td>
                      <td>libero</td>
                      <td>Sed</td>
                      <td class="shangyi">cursus</td>
                      <td class="xiayi">ante</td>
                    </tr>
                    <tr>
                      <td>1,004</td>
                      <td>dapibus</td>
                      <td>diam</td>
                      <td class="shangyi">Sed</td>
                      <td class="xiayi">nisi</td>
                    </tr>
                  </tbody>
                </table>
            </div>
            
            
            <script type="text/javascript" src="jquery.js"></script>
            <script type="text/javascript" src="bootstrap.js"></script>
            <script>
                $(function(){
                    $(".shangyi").click(function(){
                        var $currentTr = $(this).parent();
                        var $prevTr = $currentTr.prev();
                        if($prevTr){
                            $currentTr.insertBefore($prevTr);
                        }
                    });
                    $(".xiayi").on('click',function(){
                        var $currentTr = $(this).parent();
                        var $nextTr = $currentTr.next();
                        if($nextTr){
                            $currentTr.insertAfter($nextTr);
                        }
                        
                    });
                });
            </script>
        </body>
    </html>

    以上代码展示表格行点击事件的上下移动的效果,表格用到了bootstrap的样式

  • 相关阅读:
    Bootstrap使用
    Gulp
    Less和Sass
    ECMAScript6语法重点(二)
    deepin scrot-- linux下的截图工具
    iframe获取父、子窗口的方法
    测试总结--同步或异步处理过程中常见的问题
    测试总结--兼容性
    测试总结--时间/金额类字段需要关注的点
    测试总结--系统调用链路发生变更,如何评估测试范围
  • 原文地址:https://www.cnblogs.com/rocky-fang/p/5207602.html
Copyright © 2020-2023  润新知