var Circle = function() {
var obj = new Object();
obj.PI = 3.14159;
obj.area = function( r ) {
return this.PI * r * r;
}
return obj;
}
var c = new Circle();
alert( c.area( 1.0 ) );
function Circle(r) {
this.r = r;
}
Circle.PI = 3.14159;
Circle.prototype.area = function() {
return Circle.PI * this.r * this.r;
}
var c = new Circle(1.0);
alert(c.area());
var Circle={
"PI":3.14159,
"area":function(r){
return this.PI * r * r;
}
};
alert( Circle.area(1.0) );
var Circle=function(r){
this.r=r;
}
Circle.PI = 3.14159;
Circle.prototype={
area:function(){
return this.r*this.r*Circle.PI;
}
}
var obj=new Circle(1.0);
alert(obj.area()
var show={
btn:$('.div1'),
init:function(){
var that=this;
alert(this);
this.btn.click(function(){
that.change();
alert(this);
})
},
change:function(){
this.btn.css({'background':'green'});
}
}
show.init();
var contactModel; ... contactModel = new ContactModel();
function ContactModel()
{
// this.contactList;
this.crtnewFriendListLen;
this.crtNewFriendList;
this.crtFindedUserID = "-1";
if(typeof ContactModel._initialized == "undefined")
{
ContactModel.prototype.requestContactList = function()
{
}
ContactModel.prototype.requestNewfriendList = function()
{
}
ContactModel.prototype.requestFindUser = function(userID)
{
$.getJSON(mainUrl + "User/getuserinfo",{"uid":userID},function(resultObj)
{
// this.crtFindedUserID = userID
contactModel.crtFindedUserID = userID;
uiManager.contectAddPage.receiveFindUserResult(resultObj);
});
}
ContactModel.prototype.requestAddContact = function(remark)
{
alert(this.crtFindedUserID);
}
ContactModel._initialized = true;
};
}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<mce:script type=text/javascript><!--
var person=function(name,age){//定义对象构造方法
this.name=name;
this.age=age;
}
person.prototype={ //封装方法
getName:function(){
alert(this.name);
},
getAge:function(){
alert(this.age);
}
}
function test(){//声明调用
var man=new person('jack',12);
man.getName()
man.getAge()
}
var test2 ={ //类似静态方法 调用直接:test2.te();即可
te:function(){
alert();
},
te1:function(){
alert();
}
}
// --></mce:script>
</head>
<body>
<input type=button onclick="test()"/>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有