日期:2014-05-16 浏览次数:20420 次
function DB(){
}
DB.prototype.getFormData = function(){
var formData = this.getMultiSelect({
ids:"",username:"",password:"",
attach:function(){
if(arguments.length > 0){
var o = this,tr = arguments[0];
o.username += $("input[type=text]",tr).val();
o.password += $("input[type=password]:first",tr).val();
}
},
afterEnd:function(){
var o = this;//目前这里是DB实例,我希望这里是当前对象,能实现吗?
if(o.username.length >0)o.username = o.username.slice(0,-1);
if(o.password.length >0)o.password = o.password.slice(0,-1);
}
});
}
<!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>无标题文档</title>
<script type="text/javascript">
function DB() {}
DB.username="GUEST";
DB.prototype.getFormData = function () {
var d=DB.username;
return ({
username: "",
set: function () {
if (arguments.length > 0) {
this.username += arguments[0];
}
},
get: function () {
return (this.username.length > 0)? this.username.slice(0, -1):d;
}
});
}
var d=new DB();
var obj=d.getFormData();
//obj.set("xiaofanku");
alert(obj.get());
</script>
</head>
<body>
</body>
</html>