為什么鼠標(biāo)滑過(guò)顏色這么寫不對(duì)啊,劃過(guò)的時(shí)候整個(gè)表格都變色了
//鼠標(biāo)滑過(guò)的背景顏色
???? function onload2(){
??????? var table=document.getElementById("table");
??????? var trs=table.childNodes;
????????? for(var i=0;i<trs.length;i++)
????????? {
????????????? trs[i].onmouseover=function()
????????????? {
????????????????? //alert(trs.length);
????????????????? this.style.backgroundColor="#f2f2f2";
????????????? }
????????????? trs[i].onmouseout=function()
????????????? {
????????????????? this.style.backgroundColor="";
????????????? }
????????? }
??? }
2018-09-28
var trs=table.childNodes; ?這一句換成 var trs = table.getElementsByTagName("tr"); ? 我給不你了你完美的解釋!?