最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

這段JS代碼里為啥不能這樣寫

這段JS代碼里為啥不能這樣寫

慕田峪8701529 2017-11-30 22:23:17
function?Tab(oParent,child)?{ ?this.oParent=?document.getElementById(oParent); ?this.aInput?=?this.oParent.getElementsByTagName(child); ?this.aDiv?=?this.oParent.getElementsByTagName('div'); } ????Tab.prototype.init=function?()??{ for?(var?i?=?0?;?i<this.aInput.length;i++){ var?that?=?this; this.aInput[i].index=i; this.aInput[i].onclick=function?()?{?//為什么這里不能直接寫成this.aInput[i].onclick=that.change(this) that.change(this); } } Tab.prototype.change=function?(obj)?{ for(var?j=0?;j<this.aInput.length;j++){ this.aInput[j].className?=''; this.aDiv[j].style.display='none'; } obj.className?=?'active' this.aDiv[obj.index].style.display='block'; } } window.onload=function?()?{ var?tabSwitch?=?new?Tab('div1','input'); tabSwitch.init('div1')? } </script>
查看完整描述

2 回答

?
牛奶老哥哥

TA貢獻(xiàn)204條經(jīng)驗(yàn) 獲得超92個(gè)贊

你這么寫就直接在定義的時(shí)候就執(zhí)行了啊,而且這個(gè)元素的點(diǎn)擊也不會(huì)有任何事件響應(yīng).

查看完整回答
反對(duì) 回復(fù) 2017-12-01
?
cxxyjsj

TA貢獻(xiàn)119條經(jīng)驗(yàn) 獲得超22個(gè)贊

onclick屬性需要的類型是一個(gè)function, 你那么寫是一個(gè)方法調(diào)用。返回值是undefined。

查看完整回答
反對(duì) 回復(fù) 2017-12-01
  • 2 回答
  • 0 關(guān)注
  • 1338 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)