zoukankan      html  css  js  c++  java
  • 面向对象拖拽

    function Drag(){

    this.logo=document.getElementsByClassName("f-logo")[0];

    this.enter=document.getElementsByName("enter")[0];

    this.logo.onmousedown = function(e){
      _this.down(e);
      }

    }

    Drag.prototype.down = function(e){
      var _this = this;
      var e = e||event;
      this.divX = e.offsetX;
      this.divY = e.offsetY;
      document.onmousemove = function(e){
        _this.mov(e)
      }
      document.onmouseup = function(){
        _this.up()
      }
    }
    Drag.prototype.mov = function(e){
      var e = e||event;
      this.enter.style.left = e.clientX- this.divX +'px';
      this.enter.style.top = e.clientY-this.divY+'px';
    }
    Drag.prototype.up = function(){
      document.onmousemove = null;
      document.onmouseup = null;
    }

    new Drag();

  • 相关阅读:
    "Java:comp/env/"讲解与JNDI
    table的td去边框
    jsp获取所有参数
    spring-mvc设置首页
    jdbc数据库连接方式
    文件上传
    SMBMS
    过滤器和监听器
    解决Maven的JDK版本问题
    MVC
  • 原文地址:https://www.cnblogs.com/xiaocuncheng/p/8487966.html
Copyright © 2011-2022 走看看