表格列變色的作法

有關網頁及相關語法的討論
回覆文章
頭像
tim
文章: 1384
註冊時間: 2008年 11月 26日, 00:49

表格列變色的作法

文章 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>

多多留言, 整理文章, 把經驗累積下來.....
回覆文章