永发信息网

请问为什么this.aBtn[i].onclick=fnClick, fnClick 是 undefined??

答案:2  悬赏:20  手机版
解决时间 2021-02-03 17:46
  • 提问者网友:欲劫无渡
  • 2021-02-02 23:26
window.onload=function ()
{
new TabSwitch('div1');
};

function TabSwitch(id)
{
this.oDiv=document.getElementById(id);

this.aBtn=this.oDiv.getElementsByTagName('input');
this.aDiv=this.oDiv.getElementsByTagName('div');

for(var i=0;i {
this.aBtn[i].index=i;
this.aBtn[i].onclick=fnClick; // fnClic显示undefined
}
};

TabSwitch.prototype.fnClick=function (oBtn)
{
for(var i=0;i {
this.aBtn[i].className=''
this.aDiv[i].style.display='none';
}
oBtn.className='active';
this.aDiv[oBtn.index].style.display='block'
}
</script>







aaa
dfsadf
erwqerwe


最佳答案
  • 五星知识达人网友:北城痞子
  • 2021-02-02 23:49
TabSwitch.prototype.fnClick=function (oBtn)
改成
function fnClick(oBtn)
全部回答
  • 1楼网友:夜余生
  • 2021-02-03 00:08
你说呢...
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯