js css html表格选中变色

<style type="text/css">
.css_Grid1
{
padding:3px;
border:1px;
border-width:1px;
border-color:#ffee00;
width:100%;
border-collapse:collapse;
}
.css_Grid
{
color:Black;
background-color:#ffffee;
border-color:#5D7B9D;
border-width:1px;
border-style:solid;
width:450px;
}
.css_GridTR
{
color:White;
background-color:#5D7B9D;
}
td
{
font-size: 9pt;
padding:3px;
}
.css_TR_c1
{
background-color:#ffffee ;
color:#000000;
}
.css_TR_c2
{
background-color:#ffffaa ;
color:#993300;
}
.css_TR_move
{
background-color:#eaa ;
color:#123456;
}
.css_TR_CK
{
background-color:#ee0 ;
color:#333333;
}
</style>

<p><span id="MG">&nbsp;</p>
<table class="css_Grid">
    <tr class="css_GridTR">
            <td>新闻标题</td>
            <td>添加时间</td>
            <td>人气</td>
        </tr>
        <tr class="css_TR_c1" onmousemove="Move(this)" ondblclick="DbCK(me)" onclick="Ck(this,'1')" onmouseout="Out(this)">
            <td>iPhone 3G拆解图</td>
            <td>08-07-27</td>
            <td>00,002</td>
        </tr>
        <tr class="css_TR_c2" onmousemove="Move(this)" ondblclick="DbCK(me)" onclick="Ck(this,'2')" onmouseout="Out(this)">
            <td>奥运核心资源被分食 搜狐央视网谁忽悠谁?</td>
            <td>08-07-27</td>
            <td>1,234,567</td>
        </tr>
        <tr class="css_TR_c1" onmousemove="Move(this)" ondblclick="DbCK(me)" onclick="Ck(this,'3')" onmouseout="Out(this)">
            <td>微软推增强浏览器插件IE7Pro 助IE一臂之力</td>
            <td>08-07-27</td>
            <td>00,123</td>
        </tr>
        <tr class="css_TR_c2" onmousemove="Move(this)" ondblclick="DbCK(me)" onclick="Ck(this,'4')" onmouseout="Out(this)">
            <td>智联招聘70%股权换1.1亿美元巨额融资</td>
            <td>08-07-27</td>
            <td>08,888</td>
        </tr>
        <tr class="css_TR_c1" onmousemove="Move(this)" ondblclick="DbCK(me)" onclick="Ck(this,'5')" onmouseout="Out(this)">
            <td>前Google员工推搜索引擎Cuill 3倍Google网页数</td>
            <td>08-07-27</td>
            <td>00,654</td>
        </tr>
        <tr class="css_TR_c2" onmousemove="Move(this)" ondblclick="DbCK(me)" onclick="Ck(this,'6')" onmouseout="Out(this)">
            <td>WCG中国区落幕 一代新人换旧人</td>
            <td>08-07-27</td>
            <td>00,003</td>
        </tr>
    </table>
<p></span>

<script type="text/jscript" language="javascript">
        var clickClass = "";
        var moveClass = "";
        var clickTR ;
        var moveTR ;
        function Move(me)
        {
            if (clickTR != me)
            {
                if (moveTR != me)
                {
                    moveClass = me.className;
                    moveTR = me;
                    me.className = "css_TR_move";
                    //alert("a");
                }
            }  
        }
       
        function Out(me)
        {
            if (clickTR != me)
            {
                moveTR = null;
                me.className = moveClass;
            }
        }
        function Ck(me,dataID)
        {
            if (clickTR != me)
            {
                if (clickTR)
                {
                    clickTR.className = clickClass;
                }  
                clickTR = me;
                clickClass = moveClass;
            }
            me.className = "css_TR_CK";
        }
    </script>

你可能感兴趣的:(html)