<script language="javascript">
var preRow = null;
function CG(obj) 

if( preRow != null )
{
preRow.style.backgroundColor = "white"; 
}
obj.style.backgroundColor = "yellow"; 
preRow = obj;

            function Show(GCBM,GCMC,TZND, TZY)
            {
                //debugger;
                document.getElementById("td1").innerText="工程编码:"+GCBM;
                document.getElementById("td2").innerText="工程名称:"+GCMC;
                document.getElementById("td3").innerText="投资年:"+TZND;
                document.getElementById("td4").innerText="投资月:"+TZY;
                x = event.clientX + document.body.scrollLeft;
                y = event.clientY + document.body.scrollTop + 20;
                Popup.style.display="block";
                Popup.style.left = x;
                Popup.style.top = y;                
            }
            function Hide()
            {
                Popup.style.display="none";
            }
            
</script>
        if (e.Item.ItemType != ListItemType.Header)
        {;
            e.Item.Attributes.Add("onclick", "CG(this);");
        }
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF';");            e.Item.Attributes.Add("onmousemove",
                "Show('" + e.Item.Cells[0].Text.ToString() + "','"
                + e.Item.Cells[1].Text.ToString() + "','"
                + e.Item.Cells[2].Text.ToString() + "','"
                + e.Item.Cells[3].Text.ToString() + "');");
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor;Hide();");
        }
        
选中一行边成黄色
我鼠标在别的行是悬停变色鼠标移出的时候选中那行还是黄的直到选中别的行那行的黄色才没

解决方案 »

  1.   

    fengfangfang() ( )
    不明白能说明白点么
      

  2.   

    function Show(GCBM,GCMC,TZND, TZY)
                {
                    //debugger;
                    document.getElementById("td1").innerText="工程编码:"+GCBM;
                    document.getElementById("td2").innerText="工程名称:"+GCMC;
                    document.getElementById("td3").innerText="投资年:"+TZND;
                    document.getElementById("td4").innerText="投资月:"+TZY;
                    x = event.clientX + document.body.scrollLeft;
                    y = event.clientY + document.body.scrollTop + 20;
                    Popup.style.display="block";
                    Popup.style.left = x;
                    Popup.style.top = y;                
    //选中一行边成黄色鼠标在别的行时悬停变成别的颜色
    //这时候应该在别的行悬停,所以要变色,是不是这个意思?
    if(preRow==window.event.srcElement){preRow.style.backgroundColor = "black";} 
    //如果不是在选中行悬停,则变色
                }
      

  3.   

    function Hide()
                {
                    Popup.style.display="none";
    if(preRow==window.event.srcElement){preRow.style.backgroundColor = "yellow";} 
                }
      

  4.   

    还是用你以前的代码,这儿改一点点e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor;Hide();");-----〉〉e.Item.Attributes.Add("onmouseout", "if(window.event.srcElement!=preRow)this.style.backgroundColor=this.oldcolor;Hide();");
      

  5.   

    对了,onmousemove和onmouseover的变色也要判断一下window.event.srcElement!=preRowwindow.event.srcElement触发本事件的Element
      

  6.   

    <!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.2900.2963" name=GENERATOR></HEAD>
    <BODY>
    <TABLE border=1>
    <TR onclick="mouseclick(this)" onmouseout="mouseout(this)" onmouseenter="mousein(this)" onmousemove="mousemove(this)">
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    <TR onclick="mouseclick(this)" onmouseout="mouseout(this)" onmouseenter="mousein(this)" onmousemove="mousemove(this)">
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    <TR onclick="mouseclick(this)" onmouseout="mouseout(this)" onmouseenter="mousein(this)" onmousemove="mousemove(this)">
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    <TR onclick="mouseclick(this)" onmouseout="mouseout(this)" onmouseenter="mousein(this)" onmousemove="mousemove(this)">
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    <TD>a</TD>
    </TR>
    </TABLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var preRow
    function mouseout(Row)
    {
    if(Row!=preRow)
    {
    Row.style.backgroundColor="white"
    }
    }
    function mousein(Row)
    {
    if(Row!=preRow)
    {
    Row.style.backgroundColor="blue"
    }
    }
    function mousemove(Row)
    {
    if(Row!=preRow)
    {
    Row.style.backgroundColor="blue"
    }
    }
    function mouseclick(Row)
    {
    if(preRow!=null)preRow.style.backgroundColor="white"
    Row.style.backgroundColor="yellow"
    preRow=Row
    }
    //-->
    </SCRIPT>
    </BODY></HTML>