鼠标经过表格变色
来源:互联网 发布:古的网络意思 编辑:程序博客网 时间:2024/04/20 02:11
工作学习中经常会用到的代码,很实用
既可以实现隔行换色,又可以实现鼠标经过换色,鼠标移开换为原色
注:如果点击“运行代码”后没有隔行换色效果,刷新页面后可以看到效果,有点小郁闷~~~~~
应用的时候绝对没问题。
<style type="text/css" media="screen">...
table {...}{border-collapse:collapse;border:solid #999;border-width:1px 0 0 1px;}
table td {...}{border:solid #999;border-width:0 1px 1px 0;}
.t1 {...}{background-color:#fff;}/**//* 单行的背景色 */
.t2 {...}{background-color:#eee;}/**//* 双行的背景色 */
.t3 {...}{background-color:#ccc;}/**//* 鼠标经过时的背景色 */
</style>
<table width=400 align=center>
<tr><td>1</td><td>2</td></tr>
<tr><td>1</td><td>2</td></tr>
<tr><td>1</td><td>2</td></tr>
</table>
<script type="text/javascript">...
var Ptr=document.getElementsByTagName("tr");
function recolor() ...{
for (i=1;i<Ptr.length+1;i++) ...{
Ptr[i-1].className = (i%2>0)?"t1":"t2";
}
}
window.onload=recolor;
for(var i=0;i<Ptr.length;i++) ...{
Ptr[i].onmouseover=function()...{
this.tmpClass=this.className;
this.className = "t3";
};
Ptr[i].onmouseout=function()...{
this.className=this.tmpClass;
};
}
</script>
table {...}{border-collapse:collapse;border:solid #999;border-width:1px 0 0 1px;}
table td {...}{border:solid #999;border-width:0 1px 1px 0;}
.t1 {...}{background-color:#fff;}/**//* 单行的背景色 */
.t2 {...}{background-color:#eee;}/**//* 双行的背景色 */
.t3 {...}{background-color:#ccc;}/**//* 鼠标经过时的背景色 */
</style>
<table width=400 align=center>
<tr><td>1</td><td>2</td></tr>
<tr><td>1</td><td>2</td></tr>
<tr><td>1</td><td>2</td></tr>
</table>
<script type="text/javascript">...
var Ptr=document.getElementsByTagName("tr");
function recolor() ...{
for (i=1;i<Ptr.length+1;i++) ...{
Ptr[i-1].className = (i%2>0)?"t1":"t2";
}
}
window.onload=recolor;
for(var i=0;i<Ptr.length;i++) ...{
Ptr[i].onmouseover=function()...{
this.tmpClass=this.className;
this.className = "t3";
};
Ptr[i].onmouseout=function()...{
this.className=this.tmpClass;
};
}
</script>
- 鼠标经过表格变色
- 鼠标经过时,表格变色
- 表格样式:鼠标经过时表格变色
- Jquery 双色表格,鼠标经过变色
- 鼠标经过时变色的表格
- ajax-表格鼠标经过时变色
- 鼠标经过背景变色,CSSJavascript实现表格背景变色
- js--表格操纵之 鼠标经过整行变色
- 超简单表格隔行换色+鼠标经过变色2
- 表格隔行换色+鼠标经过变色(ie6,ie7,ff)
- css控制表格样式 鼠标经过变色效果
- 鼠标经过表格行时,显示变色、字体放大效果 jquery
- jQuery实现table表格隔行换色鼠标经过变色
- jQuery实现table表格隔行换色鼠标经过变色
- jq鼠标经过变色
- .net鼠标经过时变色
- css 鼠标经过文字变色
- GridView鼠标经过时变色
- XML解析技术-DOM4J解析
- linux内核文件结构和命令小结
- State模式
- XML解析技术-JDOM解析
- 在ASP.NET 2.0中使用页面导航控件
- 鼠标经过表格变色
- 再谈State
- E Commerce- a blessing for Global Sourcing
- WPF设置VistualBrush的Visual属性制作图片放大镜效果
- Automation in Delphi COM Programming
- 八数码问题的 A* 算法解答
- JavaScript面向对象编程之属性与方法
- Linux基本命令及其详解
- VB杀手V1.0.2007.1210(附源码)