移動(dòng)鼠標(biāo)改變背景顏色,以下代碼存在什么問題?
window.onload = function(){
? ? ?// 鼠標(biāo)移動(dòng)改變背景,可以通過給每行綁定鼠標(biāo)移上事件和鼠標(biāo)移除事件來改變所在行背景色。
? ? ?var tr=document.getElementsByTagName("tr");
? ? ? ? ? for(var i= 0;i<tr.length;i++)
? ? ? ? ? {
? ? ? ? ? tr[i].onmouseover=function(){
? ? ? ? ? ? tr[i].style.backgroundColor="#f2f2f2";}
? ? ? ? ? tr[i].onmouseout=function(){
? ? ? ? ? ? tr[i].style.backgroundColor="#fff";}
? ? ? ? ? }
? ? ? }
2017-05-06
貌似是不能用數(shù)組[i].onmouseover這個(gè)方法
2017-05-05
應(yīng)該使用color屬性,backgroundColor不會(huì)改變字體的顏色