表格拖拽、多列表拖拽--sortable

实现结果:两列表格可以互相拖拽

 用到的技术:

SortableJS

功能强大的JavaScript 拖拽库,官网http://www.sortablejs.com/index.html,配置项参考http://www.sortablejs.com/options.html

页面实现demo

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
    <body>
          <ul id="items">
            <li>item 1</li>
            <li>item 2</li>
            <li>item 3</li>
          </ul>
           <ul id="item">
            <li>item 4</li>
            <li>item 5</li>
            <li>item 6</li>
          </ul>
    </body>
    <script type="text/javascript">
        var el1 = document.getElementById('items');
        var el2 = document.getElementById('item');
          new Sortable(el1, {
            group: '1', // set both lists to same group
            animation: 150
        });
        
        new Sortable(el2, {
            group: '1',
            animation: 150
        });
    </script>
</html>

猜你喜欢

转载自www.cnblogs.com/qdkfyym/p/12574094.html