var $ = function(id){
return typeof id == "string" ? getElementById(id):id;
}
var Class ={
create:function(){
return function(){
this.ini.call(this,arguments);
}
}
}
var alpha = Class.create();
alpha.prototype = {
ini:function(id)
{
this.id = $(id);
}
,
hight:function(){
alert(typeof this.id.attributes);
}
,
low:function()
{
alert(typeof this.id.attributes);
}
}
var bb = new alpha("image");
bb.low();为什么 alert(typeof this.id.attributes); 结果是undefined
而如果我alert(this.id) 接过是object Object
还有我想问下ini:function(id)
{
this.id = $(id);
}
这里面的this.id是属于ini这个函数对象呢?还是属于alpha这个函数对象。因为ini这个函数是在prototype这个原型链上面··
return typeof id == "string" ? getElementById(id):id;
}
var Class ={
create:function(){
return function(){
this.ini.call(this,arguments);
}
}
}
var alpha = Class.create();
alpha.prototype = {
ini:function(id)
{
this.id = $(id);
}
,
hight:function(){
alert(typeof this.id.attributes);
}
,
low:function()
{
alert(typeof this.id.attributes);
}
}
var bb = new alpha("image");
bb.low();为什么 alert(typeof this.id.attributes); 结果是undefined
而如果我alert(this.id) 接过是object Object
还有我想问下ini:function(id)
{
this.id = $(id);
}
这里面的this.id是属于ini这个函数对象呢?还是属于alpha这个函数对象。因为ini这个函数是在prototype这个原型链上面··
解决方案 »
- 如何用JQuery实现网页DIV拖动跟其他DIV互换位置
- javascript如何判断输入的是否是汉字
- js色彩选择如何实现
- 求<tag>aaa</tag>sdfs<tag>bbb</tag>提取aaa和bbb到数组的正则表达式
- 请问怎样动态生成窗口的句柄名???
- 创建word对象出现错误的问题
- IE浏览器的“查看”菜单下为何没有“脚本调试程序”???
- 表单提交问题
- 谁能给我做一个tree menu (在netscape下能用的),我给分!!!
- 如何处理让连接地址直接下载
- 用javscript实现帮助文档,带有模糊查询既是索引功能(共同研究)
- 高手帮我看看啊。为什么 我再在外面套个函数就会出错啊
this,this,this
var $ = function(id){
return typeof id == "string" ? document.getElementById(id):id; //第一处
}
var Class ={
create:function(){
return function(){
this.ini.apply(this,arguments);//第二处
}
}
}
var alpha = Class.create();
alpha.prototype = {
ini:function(id)
{
this.id = $(id);
}
,
hight:function(){
alert(typeof this.id.attributes);
}
,
low:function()
{
alert(typeof this.id.attributes);
}
}
var bb = new alpha("image");
bb.low();
</script>