一个很简单的办法实现TD的加亮效果.
人气:0
<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>
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>
加载全部内容