請問第二高票的改變背景的兩行代碼是什么意思?如何實現(xiàn)的,麻煩詳細解答下,謝謝
var?str_tr=document.getElementsByTagName('tr'); ??????????for(var?i=0;i<str_tr.length;i++){ ???????????str_tr[i].setAttribute('onmouseover',document.all???eval(function(){this.style.background="#f2f2f2"})?:?'javascript:this.style.background="#f2f2f2"'); ???????????str_tr[i].setAttribute('onmouseout',document.all?eval(function(){this.style.background="#fff"}):'javascript:this.style.background="#fff"'); ???????}
2017-01-03
var?str_tr=document.getElementsByTagName('tr'); ?//獲取文檔中的tr元素并儲存到變量str_tr中
??????????for(var?i=0;i<str_tr.length;i++){ ?//循環(huán)遍歷str_tr中的tr
???????????str_tr[i].setAttribute('onmouseover',document.all???eval(function(){this.style.background="#f2f2f2"})?:?'javascript:this.style.background="#f2f2f2"'); ?//給str_tr中的tr設置onmouseover屬性,并三元運算判斷。應該是為了兼容的需要吧。
???????????str_tr[i].setAttribute('onmouseout',document.all?eval(function(){this.style.background="#fff"}):'javascript:this.style.background="#fff"');
???????}