码迷,mamicode.com
首页 > 其他好文 > 详细

4.2 拖放

时间:2015-02-13 16:13:22      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>拖放</title>
    <style>
        #ibox{
            width: 400px;
            height: 400px;
            float: left;
            background-color: darkgray;
        }
        #ibox2{
            width: 400px;
            height: 400px;
            float: left;
            background-color: aqua;
        }
    </style>
    <script type="text/javascript">
        function allowDrop(ev)
        {
            ev.preventDefault();
        }

        function drag(ev)
        {
            ev.dataTransfer.setData("img", ev.target.id);
        }

        function drop(ev)
        {
            ev.preventDefault();
            var data = ev.dataTransfer.getData("img");
            ev.target.appendChild(document.getElementById(data));
        }
    </script>
</head>
<body>
    <div id="ibox" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
    <div id="ibox2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
    <img id="iimg" src="raw/5.png" width="150px" height="150px" draggable="true" ondragstart="drag(event)">
</body>
</html>

技术分享

 

 

  拖放:

    http://blogs.sitepointstatic.com/examples/tech/filedrag/2/index.html

    http://www.sitepoint.com/html5-ajax-file-upload/

 

4.2 拖放

标签:

原文地址:http://www.cnblogs.com/iMirror/p/4290405.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!