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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

不明白為什么一定要用this

不明白為什么一定要用this

<!DOCTYPE html><html>?<head>? <title> new document </title>? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>? <script type="text/javascript">? ? ? window.onload = function(){? ? ? ? ? ?var trs = document.getElementsByTagName('tr');? ? ? ? ? ?for(var i = 1; i < trs.length; i++){? ? ? ? ? ? ? ? trs[i].onmouseover = function(){? ? ? ? ? ? ? ? ? ? ?this.style.backgroundColor = "#f2f2f2";? ? ? ? ? ? ? ? }//我的想法是var color=trs[i].style.backgroundColor="#f2f2f2";// trs[i].onmouseover = color;這樣是不對的但是不知道為什么? ? ? ? ? ? ? ? trs[i].onmouseout = function(){? ? ? ? ? ? ? ? ? ? ?this.style.backgroundColor = "#fff";? ? ? ? ? ? ? ? }? ? ? ? ? }? ? ? ? }? </script>?</head>?<body>? ? ?<table border="1" width="50%" id="table">? ? ?<tr>? ? <th>學(xué)號</th>? ? <th>姓名</th>? ? <th>操作</th>? ? ?</tr>? ? <tr>? ? <td>xh001</td>? ? <td>王小明</td>? ? <td><a href="#" onclick = "deleteItem(this);return false;" >刪除</a></td>? ? ?</tr>? ? ?<tr>? ? <td>xh002</td>? ? <td>劉小芳</td>? ? <td><a href="javasript:;" onclick = "deleteItem(this);" >刪除</a></td>? ? ?</tr>? ? ?</table>? ? ?<input type="button" value="添加一行" ?onclick = "addTo();"/>?</body></html>
查看完整描述

2 回答

已采納
?
李曉健

TA貢獻1036條經(jīng)驗 獲得超461個贊

window.onload?=?function(){
????????????var?trs?=?document.getElementsByTagName('tr');
????????????for(var?i?=?1;?i?<?trs.length;?i++){
//????????????????trs[i].onmouseover?=?function(){
//????????????????????//你在這里alert一下i?看看是不是你想要的值你就明白了
//????????????????????this.style.backgroundColor?=?"#f2f2f2";
//????????????????};
????????????????//如果非要用trs[i]??可以這樣試試
????????????????(function(i){
????????????????????trs[i].onmouseover?=?function(){
????????????????????????trs[i].style.backgroundColor?=?"#f2f2f2";
????????????????????}
????????????????}(i))
????????????????//我的想法是var?color=trs[i].style.backgroundColor="#f2f2f2";
????????????????//?trs[i].onmouseover?=?color;這樣是不對的但是不知道為什么

????????????????trs[i].onmouseout?=?function(){
????????????????????this.style.backgroundColor?=?"#fff";
????????????????}
????????????}
????????}

看注釋

查看完整回答
反對 回復(fù) 2015-11-23
?
echo_kinchao

TA貢獻600條經(jīng)驗 獲得超86個贊

this是特指標識

查看完整回答
反對 回復(fù) 2015-11-23
  • 2 回答
  • 0 關(guān)注
  • 1650 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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