首页 > Web开发 > 详细

json方式的面向对象、拖拽

时间:2019-04-20 22:27:58      阅读:170      评论:0      收藏:0      [点我收藏+]
//json方式的面向对象
var obj= {
    a:12,
    b:5,
    c:function(){
        alert(this.a)//12
    }
}
obj.c();//12
//命名空间
var miaov={};
miaov.common={
     myDel:function(){

      } ,
     myAdd:function(){
     
     }
};
miaov.fix={
   get:function(){
   
   },
    set:function(){
   
    }
};
miaov.common.myDel()
  • 拖拽
<script>
        window.onload=function(){
            new Drag(div1)
        };
        function Drag(id){
            var _this=this;
            this.disX=0;
            this.disY=0;
            this.oDiv = document.getElementById(id);
            thisoDiv.onmousedown=function(){
                _this.fnDown();
            };
         };
         Drag.prototype.fnDown=function(ev){
            var oEvent = ev || event;
            this.disX = oEvent.clientX - this.oDiv.offsetLeft;
            this.disY = oEvent.clientY - this.oDiv.offsetTop;
            document.onmousemove = function(){
                _this.fnMove();
            };
            document.onmouseup=function(){
                _this.fnUp();
            };
        }
        Drag.prototype.fnMove = function(ev){
            var oEvent = ev || event;
            this.oDiv.style.left = oEvent.clientX - this.disX+px;
            this.oDiv.style.top = oEvent.clientY - this.disY+px;
        };
        Drag.prototype.fnUp = function(){
            document.onmousemove=null;
            document.onmouseup=null;
        }
    </script>

 

json方式的面向对象、拖拽

原文:https://www.cnblogs.com/zhangxiaoqiong/p/10742820.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!