1 頁 (共 1 頁)

表格列變色的作法

發表於 : 2008年 11月 27日, 13:45
tim
利用 tr 的 onMouseOver 及 onMouseOut event 進行設定即可, 參考內容如下,

代碼: 選擇全部


<SCRIPT language=javascript>
<!--
function NavRollOverW(oTd) { if (!oTd.contains(event.fromElement)) {oTd.bgColor="ababee";}}
function NavRollOutW(oTd) {if (!oTd.contains(event.toElement)) {oTd.bgColor="ffffff";}}
// -->
</SCRIPT>

<table border = 1>
 <tr > 
  <td width=70>id</td><td width=200>name</td><td width=70>age</td>
 </tr>
 <tr onmouseOver="NavRollOverW(this);" onmouseOut="NavRollOutW(this);"> 
  <td width=70>1</td><td width=200>張三</td><td width=70>28</td>
 </tr>
 <tr onmouseOver="NavRollOverW(this);" onmouseOut="NavRollOutW(this);"> 
  <td width=70>1</td><td width=200>李四</td><td width=70>41</td>
 </tr>
 <tr onmouseOver="NavRollOverW(this);" onmouseOut="NavRollOutW(this);"> 
  <td width=70>1</td><td width=200>王五</td><td width=70>36</td>
 </tr>
</table>