js给看段代码,Div拖动
时间:2011-10-20
来源:互联网
say:function(){alert(12)}
}
aa.prototype={
say1:function(){
alert(125)
}
}
aa.say();
aa.say1();---这里说没有这个方法
作者: wang_137 发布时间: 2011-10-20
var aa=function(){ this.say=function(){alert(12)} } aa.prototype.say1=function(){ alert(125) } var b=new aa(); b.say(); b.say1()
作者: BLUE_LG 发布时间: 2011-10-20
该回复于2011-10-20 13:58:28被管理员删除
- 对我有用[0]
- 丢个板砖[0]
- 引用
- 举报
- 管理
- TOP
|
#3楼 得分:0回复于:2011-10-20 13:38:07
|
作者: bustersword 发布时间: 2011-10-20
aa.say=function(){};
aa.say1=function(){};
aa.say2=function(){};
作者: wang_137 发布时间: 2011-10-20
function aa(){ this.say=function(){alert(12)} } aa.prototype={ constructor:aa, say1:function(){ alert(125) } } var wori=new aa() wori.say(); wori.say1();
作者: ifandui 发布时间: 2011-10-20
刚才你
aa.prototype={
say1:function(){
alert(125)
}
只是给aa添加了一个名为prototype的成员变量
var aa={
say:function(){alert(12)}
}
如果想添加say1方法,只需添加一个名为say1的成员变量就可以
aa.say1 = functino(){
//dosth
}
作者: ycmjh2010 发布时间: 2011-10-20
var moveBox={ version:1.0, source:null, movable:false,//movable mousePosition:null, mpSource:null,//mouse position to source Client:function(s){//bound element moveBox.source=$("#"+s); this.register(this); } } moveBox.Client.prototype ={ getMPSource:function(e){//mouse position to source return { rx:e.offsetX?e.offsetX:e.layerX, ry:e.offsetY?e.offsetY:e.layerY } }, getMousePosition:function(e){ if(e.pageX || e.pageY){ return {x:e.pageX, y:e.pageY}; } return { x:e.clientX + document.body.scrollLeft - document.body.clientLeft, y:e.clientY + document.body.scrollTop - document.body.clientTop } }, register:function(o){ moveBox.source.mousedown(function(e){ moveBox.movable=true; moveBox.mpSource=o.getMPSource(e); }); moveBox.source.mouseup(function(e){ moveBox.movable=false; moveBox.mpSource=null; }); moveBox.source.mousemove(function(e){ if(moveBox.movable){ moveBox.mousePosition=o.getMousePosition(e); moveBox.source.css("left",moveBox.mousePosition.x-moveBox.mpSource.rx); moveBox.source.css("top",moveBox.mousePosition.y-moveBox.mpSource.ry); } }); $(document).mouseup(function(){ if(moveBox.movable) moveBox.movable=false; }); } } var client=new moveBox.Client("move");
终于完成了,兼容浏览器,但感觉写的有点别扭
贴出来只是希望大牛们能改的优雅些
作者: liangws 发布时间: 2011-10-20
JScript code
var aa={ say:function(){alert(12);} }; aa.__proto__.say1=function() { alert(125); } aa.say(); aa.say1();
或者
JScript code
function aa() { this.say = function(){alert(12);} } aa.prototype={ say1:function(){ alert(125); } }; var a = new aa(); a.say(); a.say1();
具体楼主可以看看关于原型的内容。
作者: wang_137 发布时间: 2011-10-20
只有方法才有这个
作者: Legend1988 发布时间: 2011-10-20
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28