js兼容標(biāo)準(zhǔn)的表格變色效果
更新時間:2008年06月28日 17:14:24 作者:
符合標(biāo)準(zhǔn)的表格變色的js代碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
* { margin:0; padding:0; font-size:14px }
body { text-align:center;}
#btn { list-style:none inside; width:210px; margin:10px auto; clear:both; }
#btn li { float:left; width:100px; line-height:20px }
#btn li a{ display:block; text-decoration:none; color:#333333}
#gray { background:#f5f5f5; cursor: pointer }
#green { background:#D7ECDE; cursor:pointer }
table { border-collapse:collapse; width:70%; margin:10px auto }
td { line-height:100%; height:24px; line-height:24px; padding:0 4px }
td a { text-decoration:none; color:#333; display:block; }
#tab_gray td { border:1px solid #B9B9B9; background: #F2F2F2; }
#tab_green td { border:1px solid #95CCA7; background:#EBF5EE; }
#tab_gray td:hover, #tab_green td:hover { background:#fff; }
</style>
</head>
<body>
<ul id="btn">
<li id="gray"><a href="javascript:void()" onclick="gray()">gray</a></li>
<li id="green"><a href="javascript:void()" onclick="green()">green</a></li>
</ul>
<table id="tab_gray">
<tr>
<td><a href="#">Table</a></td>
<td><a href="#">Table</a></td>
<td><a href="#">Table</a></td>
</tr>
<tr>
<td>hello</td>
<td>hello</td>
<td>hello</td>
</tr>
<tr>
<td>hello</td>
<td>hello</td>
<td>hello</td>
</tr>
</table>
<script language="javascript">
function green(){
document.getElementById("tab_gray").id="tab_green";
}
function gray(){
document.getElementById("tab_green").id="tab_gray";
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
* { margin:0; padding:0; font-size:14px }
body { text-align:center;}
#btn { list-style:none inside; width:210px; margin:10px auto; clear:both; }
#btn li { float:left; width:100px; line-height:20px }
#btn li a{ display:block; text-decoration:none; color:#333333}
#gray { background:#f5f5f5; cursor: pointer }
#green { background:#D7ECDE; cursor:pointer }
table { border-collapse:collapse; width:70%; margin:10px auto }
td { line-height:100%; height:24px; line-height:24px; padding:0 4px }
td a { text-decoration:none; color:#333; display:block; }
#tab_gray td { border:1px solid #B9B9B9; background: #F2F2F2; }
#tab_green td { border:1px solid #95CCA7; background:#EBF5EE; }
#tab_gray td:hover, #tab_green td:hover { background:#fff; }
</style>
</head>
<body>
<ul id="btn">
<li id="gray"><a href="javascript:void()" onclick="gray()">gray</a></li>
<li id="green"><a href="javascript:void()" onclick="green()">green</a></li>
</ul>
<table id="tab_gray">
<tr>
<td><a href="#">Table</a></td>
<td><a href="#">Table</a></td>
<td><a href="#">Table</a></td>
</tr>
<tr>
<td>hello</td>
<td>hello</td>
<td>hello</td>
</tr>
<tr>
<td>hello</td>
<td>hello</td>
<td>hello</td>
</tr>
</table>
<script language="javascript">
function green(){
document.getElementById("tab_gray").id="tab_green";
}
function gray(){
document.getElementById("tab_green").id="tab_gray";
}
</script>
</body>
</html>
您可能感興趣的文章:
- JS控制表格隔行變色
- javascript實現(xiàn)table表格隔行變色的方法
- js實現(xiàn)鼠標(biāo)經(jīng)過表格行變色的方法
- 原生JS操作網(wǎng)頁給p元素添加onclick事件及表格隔行變色
- 一個簡單但常用的javascript表格樣式_鼠標(biāo)劃過行變色 簡潔實現(xiàn)
- javascript基于jQuery的表格懸停變色/恢復(fù),表格點擊變色/恢復(fù),點擊行選Checkbox
- 高效的表格行背景隔行變色及選定高亮的JS代碼
- 用JS控制表格的逐行變色的表單
- javascript表格隔行變色加鼠標(biāo)移入移出及點擊效果的方法
- JS實現(xiàn)表格隔行變色
相關(guān)文章
layui點擊左側(cè)導(dǎo)航欄,實現(xiàn)不刷新整個頁面,只刷新局部的方法
今天小編就為大家分享一篇layui點擊左側(cè)導(dǎo)航欄,實現(xiàn)不刷新整個頁面,只刷新局部的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09
js自動閉合html標(biāo)簽(自動補全html標(biāo)記)
假如我有一個DIV,如果沒有閉合后面的樣式都會亂了,這樣的代碼可能會影響后面的樣式,我希望用JS去自動閉合這種沒有閉合的標(biāo)簽2012-10-10
JavaScript中toLocaleString()和toString()的區(qū)別實例分析
這篇文章主要介紹了JavaScript中toLocaleString()和toString()的區(qū)別,結(jié)合實例形式對比分析了toLocaleString()和toString()針對字符串、數(shù)組與日期操作過程中的區(qū)別與使用技巧,需要的朋友可以參考下2018-08-08
JavaScript 數(shù)組- Array的方法總結(jié)(推薦)
下面小編就為大家?guī)硪黄狫avaScript 數(shù)組- Array的方法總結(jié)(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-07
微信JSSDK實現(xiàn)打開攝像頭拍照再將相片保存到服務(wù)器
這篇文章主要介紹了微信JSSDK實現(xiàn)打開攝像頭拍照再將相片保存到服務(wù)器,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11
使用clipboard.js實現(xiàn)復(fù)制功能的示例代碼
本篇文章主要介紹了使用clipboard.js實現(xiàn)復(fù)制功能的示例代碼,詳細(xì)介紹了clipboard.js插件的使用,有興趣的可以了解一下2017-10-10

