zoukankan      html  css  js  c++  java
  • 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页

  • 相关阅读:
    day16(链表中倒数第k个结点)
    day15(C++格式化输出数字)
    day14(调整数组顺序使奇数位于偶数前面 )
    day13(数值的整数次)
    day12(二进制中1的个数)
    day11(矩形覆盖)
    day10(跳台阶)
    hadoop 又一次环境搭建
    Hive 学习
    hadoop -工具合集
  • 原文地址:https://www.cnblogs.com/diligenceday/p/3508039.html
Copyright © 2011-2022 走看看