初学jQuery的js 问题,请达人指教
飞火流云 2010-04-23 07:55:27 代码如下:
自己定义了一个test.js,里面定义了两个类:
/**
@namespace JavaScript framework
*/
$.student = {
name : "li",
age : 18 ,
sex : "M",
score : "",
set_age: function(a)
{
age= a;
return a;
},
set_name: function(n) { name=n; return n; }
,
print: function() { alert(sum);},
get_age: function() { alert(name); return name; }
};
var stu = $.student;
$.teacher = {
version: "1.0",
sdt: stu ,
getStuAge:function(){
alert("getStuAge");
return stu.get_age();
}
};
然后在html页面中调用:
alert($.teacher.getStuAge());
发现弹出的对话框为"age is not defined ", 不理解, 是因为没有初始化对象么? 还是说像Java一样? 初始化对象然后调用?