zoukankan      html  css  js  c++  java
  • 表格单元格间数据的拖拽

    <!DOCTYPE HTML>
    <html>
    <style>
        td{
            border:1px solid #444;
            padding:20px;
            width:100px;
            height:50px;
        }
        td div{
            cursor:pointer;
        }
        table{
           
        }
    </style>
     
    <script type="text/javascript">
    function allowDrop(ev)
    {
    ev.preventDefault();
    }
    
    function drag(ev)
    {
    ev.dataTransfer.setData("Text",ev.target.id);
    }
    
    function drop(ev)
    {
    ev.preventDefault();
    var data=ev.dataTransfer.getData("Text");
    ev.target.appendChild(document.getElementById(data));
    }
    </script>
    <body>
            <p>asldflasl</p>
        <table>
            <tr>
                <th>
                a
                </th><th>
    b
    </th><th>
    c
    </th><th>
    d
    </th><th>
       e
    </th>
            </tr>
            <tr>
                <td class="mytd" ondrop="drop(event)" ondragover="allowDrop(event)">
                    <div id="div1" class="tablediv" draggable="true" ondragstart="drag(event)" >1111111</div>
                </td>
                <td class="mytd" ondrop="drop(event)" ondragover="allowDrop(event)">
                    <div id="div2" class="tablediv" draggable="true" ondragstart="drag(event)" >2222222</div>
                </td>
                <td class="mytd" ondrop="drop(event)" ondragover="allowDrop(event)">
                    <div id="div3" class="tablediv" draggable="true" ondragstart="drag(event)" >333333333</div>
                </td>
                <td class="mytd" ondrop="drop(event)" ondragover="allowDrop(event)">
                    <div id="div4" class="tablediv" draggable="true" ondragstart="drag(event)" >4444444444</div>
                </td>
                <td>
                    <div class="tablediv">555555555555</div>
                </td>
            </tr>
        </table>
    
    
    </body>
    </html>
  • 相关阅读:
    LR与SVM的异同
    精确率,召回率
    XgBoost推导与总结
    梯度下降中的步长选择-线性搜索
    页面去掉某个css属性
    composer 安装某个插件后 引入方法
    javascript,检测对象中是否存在某个属性
    js 计算字符串长度 中文为2 英文为1
    laravel 新手 =_= 持续更新
    php compact() 函数
  • 原文地址:https://www.cnblogs.com/lunawzh/p/4888625.html
Copyright © 2011-2022 走看看