color();里面這三個是代表什么意思
?window.onload = function(){
? ? ? ? ? color();
? ? ? } ? ? ??
? ? ?// 鼠標移動改變背景,可以通過給每行綁定鼠標移上事件和鼠標移除事件來改變所在行背景色。
? ? ?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"};
}?
? ? ?}
? ? ? ? ?
? ? ? // 編寫一個函數,供添加按鈕調用,動態在表格的最后一行添加子節點;
? ?
? ? ? ? ? ?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>放入數組list
for(i=1;i<list.length;i++){ ? //循環
? ? list[i].onmouseover=function(){this.style.backgroundColor="red"};//設置第i行鼠標移入事件
? ? ? ? ?list[i].onmouseout=function(){this.style.backgroundColor="#fff"};//設置第i行鼠標移出事件