函數(shù)里第一行代碼為什么獲取的是lastChild??
function Highlight(){
var tbody = document.getElementById('table').lastChild;
trs = tbody.getElementsByTagName('tr');? ?
for(var i =1;i<trs.length;i++){
trs[i].onmouseover = function(){
this.style.backgroundColor ="#f2f2f2";
}?
trs[i].onmouseout = function(){
this.style.backgroundColor ="#fff";
}?
}??
}
2018-04-25
整段代碼意思是給最后一行實(shí)現(xiàn)要求一(1.鼠標(biāo)移到不同行上時(shí)背景色改為色值為 #f2f2f2,移開鼠標(biāo)時(shí)則恢復(fù)為原背景色 #fff),沒估計(jì)錯(cuò)的話,應(yīng)該是給添加的新行的代碼調(diào)用的
2018-05-09
但是最后一個(gè)子節(jié)點(diǎn)可能是空格組成的文本節(jié)點(diǎn),這樣獲取可能會有問題,除非先把空節(jié)點(diǎn)去掉