鼠标移动上去变换背景色

 

1.用样式名
注意:是this.className  而不是this.style.className

代码
<div class="subnavi-bottom">
<ul>
<li onmouseover="this.className='white12b current'" onmouseout="this.className='black12b'" class="black12b">&gt; 公司简介</li>

<li onmouseover="this.className='white12b current'" onmouseout="this.className='black12b'"><a href="#">&gt; 企业荣誉</a></li>
<li onmouseover="this.className='white12b current'" onmouseout="this.className='black12b'"><a href="#">&gt; 组织架构</a></li>
</ul>
</div>

 2.直接用样式

代码
StringBuilder sb = new StringBuilder();
string str_Sql = "select * from ProductClass where len(ClassRelation)=3";
DataTable DT
= PubAccessHelperFunc.GetDataTable(str_Sql);
if (DT.Rows.Count > 0)
{
for (int i = 0; i < DT.Rows.Count; i++)
{
sb.AppendLine(
"<tr onmouseover=\"this.bgColor='#7AB51E';document.getElementById('img" + i + "').src='images/icon.gif';\" onmouseout=\"this.bgColor='';document.getElementById('img" + i + "').src='images/icon1.gif';\">");
sb.AppendLine(
"<td align=\"center\" ><img src=\"images/icon1.gif\" width=\"4\" height=\"9\" id=\"img"+i+"\" /></td>");
sb.AppendLine(
"<td><a class=\"t\" href=\"Food.aspx?CR="+DT.Rows[i]["ClassRelation"].ToString()+"\">"+DT.Rows[i]["ClassName"].ToString()+"</a>");
sb.AppendLine(
"</td>");
sb.AppendLine(
"</tr>");
}
}
else
{
ltl_Class.Text
= "<center style=\"color:red;\">暂无!</center>";
}

 

代码
用户名: <input class="username" style="background-

color:black;color:'#FF9933';"
onmouseover="this.style.borderColor='#669999'" onmouseout="this.style.borderColor='#A1BCA3'" maxLength="12" name="username">
&nbsp;密码: <input id="password" class="username1" style="background-

color:black;color:'#FF9933';"
onmouseover="this.style.borderColor='#669999'" onmouseout="this.style.borderColor='#A1BCA3'" type="password"

name
="password"> </td>

onmouseout="this.style.backgroundColor='';"

posted @ 2010-01-07 17:09  TiTi  阅读(1570)  评论(0编辑  收藏  举报