color();里面這三個(gè)是代表什么意思
?window.onload = function(){
? ? ? ? ? color();
? ? ? } ? ? ??
? ? ?// 鼠標(biāo)移動(dòng)改變背景,可以通過(guò)給每行綁定鼠標(biāo)移上事件和鼠標(biāo)移除事件來(lái)改變所在行背景色。
? ? ?function color(){
? ? ? ? ?var list =document.getElementsByTagName("tr");
for(i=1;i<list.length;i++){
? ? list[i].onmouseover=function(){this.style.backgroundColor="red"};
? ? ? ? ?list[i].onmouseout=function(){this.style.backgroundColor="#fff"};
}?
? ? ?}
? ? ? ? ?
? ? ? // 編寫(xiě)一個(gè)函數(shù),供添加按鈕調(diào)用,動(dòng)態(tài)在表格的最后一行添加子節(jié)點(diǎn);
? ?
? ? ? ? ? ?function append(){
? ? ? ? ?var id=document.getElementById("table").lastChild;?
? ? ?
? ? ? ? ?var newnode=document.createElement("tr");
? ? ? ? ?id.appendChild(newnode);
? ? ? ? ? ?
? ? ? ? ?var newnode1=document.createElement("td");
? ? ? ? ? newnode1.innerHTML="xh003";
? ? ? ? ? newnode.appendChild(newnode1);
? ? ? ? ??
? ? ? ? ? var newnode2=document.createElement("td");
? ? ? ? ? newnode2.innerHTML="韋小寶";?
? ? ? ? ? newnode.appendChild(newnode2);
? ? ? ? ??
? ? ? ? ? var newnode3=document.createElement("td");
? ? ? ? ? newnode3.innerHTML= "<a href='javascript:' onclick='lete(this)'>刪除</a>";
? ? ? ? ? newnode.appendChild(newnode3);
? ? ? ? ? ?color();
? ? ? ? ?}
? ? ? ? ? ? ? ?
2016-10-17
?var list =document.getElementsByTagName("tr"); ?//獲取所有<tr>放入數(shù)組list
for(i=1;i<list.length;i++){ ? //循環(huán)
? ? list[i].onmouseover=function(){this.style.backgroundColor="red"};//設(shè)置第i行鼠標(biāo)移入事件
? ? ? ? ?list[i].onmouseout=function(){this.style.backgroundColor="#fff"};//設(shè)置第i行鼠標(biāo)移出事件