当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 一个很简单的办法实现TD的加亮效果.

Javascript
AJAX教程(14):通过XMLHTTP加载XML文件
AJAX教程(15):通过XMLHTTP进行一次HEAD请求
AJAX教程(16):通过XMLHTTP进行一次指定的HEAD请求
AJAX教程(17):把XML文件显示为HTML表格
JS通过WMI获取客户端硬件信息
JavaScript中使用远程脚本
关于Ajax技术的注意事项
XMLHttpRequest创建智能表单
iframe创建智能表单
JS教程:线小测试程序
在Web页面中使用计时器
将事件处理器作为HTML标记的属性
事件处理器作为浏览器对象的属性
Math对象应用详解
random()方法和pow()方法
charAt()方法和charCodeAt()方法
Number对象常用的toFixed()方法
JS教程:为什么尽量用局部变量代替全局变量
解决JavaScript循环中的过多操作
处理提示“脚本运行时间过长的提示框”问题

Javascript 中的 一个很简单的办法实现TD的加亮效果.


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 195 ::
收藏到网摘: n/a

<script>
function Menu_Init(obj){
var tds = obj.getElementsByTagName("td");
for (var i = 0; i < tds.length; i++)
{
if (tds[i].className == "MenuOptions")
{
tds[i].onmouseover = switch_bg;
tds[i].onmouseout = switch_bg;
}
}
}
function switch_bg(e){
if (this.className=="MenuOptions_click") return
this.className = (this.className == "MenuOptions") ? "MenuOptions_hilite" : "MenuOptions";
}
</script>
<style>
.MenuOptions{
padding:2px;
cursor:hand;
color:#000000;
}
.MenuOptions_hilite{
padding:1px;
border:outset 1px #669999;
cursor:hand;
color:#000000;
}
</style>
<table id=MenuTools border="0" cellspacing="2" style="border:1px solid #000000;color:#000000;font-size:12px">
<tr>
<td class="MenuOptions" >大家好呀
<td class="MenuOptions" >很容易实现的效果
<td class="MenuOptions" >喜欢的就拿去用吧
<td >这个不允许加亮
</tr>
</table>
<script>Menu_Init(MenuTools)</script>