javascript: prototype 事件处理函数调用prototype内部函数
悬赏分:20 - 离问题结束还有 14 天 16 小时
function base()
{
this.obj = document.getElementById("bt");
} base.prototype.func1 = function(index)
{
} base.prototype.func2 = function()
{
//下面的是一个事件处理函数
this.obj.onclick = function()
{
// 在这里我想调用 func1 函数,请问代码要怎样写
}
}问题补充: 使用 this.func1 调用时,this指向的不是base,而是 this.obj
悬赏分:20 - 离问题结束还有 14 天 16 小时
function base()
{
this.obj = document.getElementById("bt");
} base.prototype.func1 = function(index)
{
} base.prototype.func2 = function()
{
//下面的是一个事件处理函数
this.obj.onclick = function()
{
// 在这里我想调用 func1 函数,请问代码要怎样写
}
}问题补充: 使用 this.func1 调用时,this指向的不是base,而是 this.obj
function base()
{
this.obj = document.getElementById("bt");
} base.prototype.func1 = function(index)
{
} base.prototype.func2 = function()
{
//下面的是一个事件处理函数
var a=new base();
a.obj.onclick = function()
{
// 在这里我想调用 func1 函数,请问代码要怎样写
alert('测试成功!');
}
}
</script>
<input name="bt" type="text" value="" />
不知道你是不是想要这样的?
更新