• HTML5的拖拽时间 ondragstart


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>dragable</title>
    </head>
    <body>
    <h1  draggable="true">time</h1>
    <span id="clock" draggable="true">time_span</span>
    <img src="12.png" />
    <textarea cols="60" rows="20"></textarea>
    <script>
    (function(){
        var clock = document.getElementById('clock');
        var icon = new Image();
        icon.src = "12.png";
        
        function displayTime(){
            var now = new Date();
            clock.innerHTML = now.getMinutes();
            setTimeout(arguments.callee,6000);
        };
        displayTime();
        
        clock.ondragstart = function(ev){
            var dt = ev.dataTransfer; //event里面有一个dataTransfer,这栋西很重要,setData,就是将数据保存到一个缓冲中,然后,就可以放到textarea看到数据了
            dt.setData("Text",Date(),"
    ");
            if(dt.setDargImage)dt.setDragImage(icon,0,0)
        }
    })()
    </script>
    </body>
    </html>

    //来自于西牛叔 p472页

  • 相关阅读:
    python学习day3--python基础
    python学习day2--python基础
    python学习day1--python基础
    包导入原则
    模块搜索路径
    继承顺序
    继承,派生,组合
    面向对象程序设计
    类和对象
    递归
  • 原文地址:https://www.cnblogs.com/diligenceday/p/3508039.html
Copyright © 2020-2023  润新知