6 回答

TA貢獻446條經(jīng)驗 獲得超754個贊
? <script type="text/javascript">?
? ? ? window.onload = function(){
? ? ? ? ? ? ? ? var h=document.getElementsByTagName('tr');
? ? ? ? ? ? ? ? for(i=0;i<h.length;i++){
? ? ? ? ? ? ? ? h[i].onmouseover=change;
? ? ? ? ? ? ? ? }
}
? ? ? ? ?function change(){
? ? ?this.style.backgroundColor="#f2f2f2";
? ? ? ? ?}
? </script>?

TA貢獻13條經(jīng)驗 獲得超8個贊
for(i=0;i<h.length;i++){
? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? h[i].onmouseover=change;
添加事件 ?和添加屬性 不一樣

TA貢獻446條經(jīng)驗 獲得超754個贊
?<script type="text/javascript">?
? ? ? window.onload = function(){
? ? ? ? ? ? ? ? var h=document.getElementsByTagName('tr');
? ? ? ? ? ? ? ? for(i=0;i<h.length;i++){
? ? ? ? ? ? ? ? h[i].setAttribute("onmouseover",'change.apply(this)');
? ? ? ? ? ? ? ? }
}
? ? ? ? ?function change(){
? ? ?this.style.backgroundColor="#f2f2f2";
? ? ? ? ?}
? </script>?

TA貢獻446條經(jīng)驗 獲得超754個贊
? <script type="text/javascript">?
? ? ? window.onload = function(){
? ? ? ? ? ? ? ? var h=document.getElementsByTagName('tr');
? ? ? ? ? ? ? ? for(i=0;i<h.length;i++){
? ? ? ? ? ? ? ? h[i].setAttribute("onmouseover",'change(this)');
? ? ? ? ? ? ? ? }
}
? ? ? ? ?function change(self){
? ? ?self.style.backgroundColor="#f2f2f2";
? ? ? ? ?}
? </script>
添加回答
舉報