<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0011)about:blank -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2800.1528" name=GENERATOR>
</HEAD>
<BODY>
<form action="http://www.baidu.com">
<table>
<tr>
<td onmouseover="this.style.backgroundImage='url(xg.jpg)'" onmouseout="this.style.backgroundImage='url(xgg.jpg)'" style="{width:680;height:384}">test
</td>
</tr>
</table>
</form>
</BODY>
</HTML>

解决方案 »

  1.   

    是不是这个效果?自己测一下吧要有两张图片,xg.jpg和xgg.jpg
      

  2.   

    修改
    for (i=0;i<=12;i++)
    {
    var id;
    id="img" + MenuId;
    document.getElementById(id).style.backgroundImage  ="url(http://localhost/test/Frame/layout/menu_bg_no.png)";
    event.srcElement.style.backgroundImage=": url(http://localhost/test/Frame/layout/menu_bg_yes.png)";
    }
      

  3.   

    for (i=0;i<=12;i++)
    {
    var id;
    id="img" + MenuId;
    document.getElementById(id).style.backgroundImage  ="url(http://localhost/test/Frame/layout/menu_bg_no.png)";
    event.srcElement.style.backgroundImage="url(http://localhost/test/Frame/layout/menu_bg_yes.png)";
    }
      

  4.   

    按照各位大哥的指点,我的修改如下
    private void InitToolBar()
    {
     
    // 可以通过传递参数来控制单元格的宽度和高度
       lblCode.Text += "<TABLE id='Table1' cellSpacing='1' cellPadding='1' width=100% height='40' border='0'><TR>"; for(int k = 0 ; k < ds.Tables[0].Rows.Count ; k++)
    {

    string title = ds.Tables[0].Rows[0]["UserName"].ToString();
    string id = "img" + k.ToString();
    lblCode.Text +="<TD id = " + id + " align = center style='BACKGROUND-IMAGE: url(http://localhost/test/Frame/layout/menu_bg_no.png)'><A onclick='javascript:ShowMenu();' href='#'>"  + title + "</a></TD>";
    }
    lblCode.Text += "</TR></TABLE>";
    }
    function ShowMenu(){
    var id;
    //var tab;
    //var bag2 = "Frame/layout/1.png";
    // 如何替换指定单元格的背景图片
    //bag2 = " url(" + bag2 + ")no-repeat top center";
    //document.getElementById("id").style.backgroundImage=bag2;
    for (i = 0 ; i < 12 ; i++)
    {
    id = "img" + i;
    document.getElementById(id).style.backgroundImage = "url(http://localhost/test/Frame/layout/menu_bg_no.png)";
    event.srcElement.style.backgroundImage = "url(http://localhost/test/Frame/layout/1.png)";
    }
    }但好象还是替换不了哦,不知道怎么回事情,指点点了哪个连接后其就变白了,郁闷中,还望大家鼎力相助啊!!!