• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

表格 行 拖动 复制粘贴即可用

武飞扬头像
cuilll
帮助1

TableDnD | jQuery plug-in to drag and drop rows in HTML tables
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://blog.csdn.net/js/jquery-3.5.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/TableDnD/0.9.1/jquery.tablednd.js" integrity="sha256-d3rtug Hg1GZPB7Y/yTcRixO/wlI78 2m08tosoRn7A=" crossorigin="anonymous"></script>
</head>
<body>
<table id="table-1" cellspacing="0" cellpadding="2">
    <tr id="1"><td>1</td><td>One</td><td>1 text</td></tr>
    <tr id="2"><td>2</td><td>Two</td><td>2 text</td></tr>
    <tr id="3"><td>3</td><td>Three</td><td>3 text</td></tr>
    <tr id="4"><td>4</td><td>Four</td><td>4 text</td></tr>
    <tr id="5"><td>5</td><td>Five</td><td>5 text</td></tr>
    <tr id="6"><td>6</td><td>Six</td><td>6 text</td></tr>
</table>

<div id="debugArea"></div>

<script type="text/javascript">
    $(document).ready(function() {
        // Initialise the table
        $("#table-1").tableDnD({
            onDragClass: "myDragClass",
            onDrop: function(table, row) {
                var rows = table.tBodies[0].rows;
                var debugStr = "Row dropped was " row.id ". New order: ";
                for (var i=0; i<rows.length; i  ) {
                    debugStr  = rows[i].id " ";
                }
                $("#debugArea").html(debugStr);
            },
            onDragStart: function(table, row) {
                $("#debugArea").html("Started dragging row " row.id);
            }
        })
    });
     $("#table-1 tr:even").addClass('alt')
    $("#table-1").onDragStop=function (table,row) {
        console.log(table)
        console.log(row)

    }
</script>
</body>
</html>
学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfkbaak
系列文章
更多 icon
同类精品
更多 icon
继续加载