第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

變色為什么要嵌套才行了,直接寫沒效果呢

????? window.onload = function(){
????? var tr = document.getElementsByTagName("tr");

????????? for (var i=0;i<tr.length; i++) {

????????????? bgChange(tr[i]);

????????? }

???

? }

?// 鼠標(biāo)移動(dòng)改變背景,可以通過給每行綁定鼠標(biāo)移上事件和鼠標(biāo)移除事件來改變所在行背景色。

???? function bgChange(a) {

???????? a.onmouseover=function()

???????? {

???????? a.style.backgroundColor="#f2f2f2";

???????? }

??????? a.onmouseout=function()

???????? {

???????? a.style.backgroundColor="#fff";

???????? }

?}


????

正在回答

4 回答

你這樣寫就可以了

var tr = document.getElementsByTagName("tr");

? ? ? ? ? for (var i=0;i<tr.length; i++) {

? ?

? ? ? ? ? ?tr[i].onmouseover=function()

? ? ? ? ? ? ?{

? ? ? ? ? ? ? ? this.style.backgroundColor="#f2f2f2";

? ? ? ? ? ? ?}

? ? ? ? ?tr[i].onmouseout=function()

? ? ? ? ? ? ?{

? ? ? ? ? ? ? ? this.style.backgroundColor="#fff";

? ? ? ? ? ? ?}

? }


0 回復(fù) 有任何疑惑可以回復(fù)我~

問題出在onmouseover=function(),這樣寫就相當(dāng)于當(dāng)onmouseover時(shí),執(zhí)行下function()里的代碼,并不是給tr[i]的事件綁定方法

你試下直接在里面輸出i,發(fā)現(xiàn)無論你移動(dòng)到哪一條,i的值都不會(huì)變

0 回復(fù) 有任何疑惑可以回復(fù)我~

window.onload = function(){
????? var tr = document.getElementsByTagName("tr");

????????? for (var i=0;i<tr.length; i++) {

?????????? tr[i].onmouseover=function()

???????? {

???????? a.style.backgroundColor="#f2f2f2";

???????? }
???????? tr[i].onmouseout=function()

???????? {

???????? a.style.backgroundColor="#fff";

???????? }

??? }
?

? }

?

0 回復(fù) 有任何疑惑可以回復(fù)我~

應(yīng)該是可以的,你直接寫沒有效果,可能是你定錯(cuò)了,可以把你說的沒有效果的代碼發(fā)出來看看

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

whh168 提問者

window.onload = function(){var tr = document.getElementsByTagName("tr");for (var i=0;i<tr.length; i++) { tr[i].onmouseover=function(){a.style.backgroundColor="#f2f2f2"; } tr[i].onmouseout=function(){a.style.backgroundColor="#fff";}}}
2015-02-10 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

變色為什么要嵌套才行了,直接寫沒效果呢

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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