phpma
级别: 管理员
UID: 1
精华: 6
发帖: 270
威望: 318 点
金钱: 2820 RMB
贡献值: 0 点
注册时间:2007-05-17
最后登录:2008-12-27
楼主  发表于: 2007-08-01 13:53

 用js函数实现图片切换效果代码

一个超好用的代码……来源:http://bond.money.hexun.com/ 中的国债、企业债的图片鼠标点击切换
全部代码如下: 以经很完善了……


<script>
                function ChangeIndexPic(nIndex)
                {   
                    document.getElementById("type1").className="f01_out";
                    document.getElementById("type2").className="f01_out";

                    if(nIndex == 1)
                    {
                        document.getElementById("indexhref").href="/data/index.aspx";
                        document.images["indexpic"].src="http://quote.stock.hexun.com/WebPic/SH/Min/000012_msn.gif";
                        document.getElementById("type1").className="f01_on";
                    }
                    if(nIndex == 2)
                    {
                        document.getElementById("indexhref").href="/data/index.aspx";
                        document.images["indexpic"].src="http://quote.stock.hexun.com/WebPic/SH/Min/000013_msn.gif";
                        document.getElementById("type2").className="f01_on";
                    }
                }
           
</script>
   
    <TABLE height="25" cellSpacing=0 cellPadding=0 width="100%" border=0 background="images/r_200.gif" style="BORDER-RIGHT:#00976C 1px solid;">
      <TBODY>
        <TR><div class="f01_tr">
          <td width="100" height="25" class="f01_on" id="type1" onclick="ChangeIndexPic(1)" style="CURSOR:pointer"> </td>
          <td  width="100" height="25" class="f01_out" id="type2" onclick="ChangeIndexPic(2)" style="CURSOR:pointer"> </td></div>
        </TR>
      </TBODY>
    </TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="200" border=0  style="BORDER-RIGHT:#00976C 1px solid; BORDER-left: #00976C 1px solid;BORDER-BOTTOM: #00976C 1px solid ; BORDER-top: #00976C 1px solid">
          <tr>
            <td>
            <table border="0" width="100%" cellpadding="0" cellspacing="0">
                <tr><td align="center">
        <div class="f01_c">
        <div style="FLOAT:left; width:190px;" id="indexhref">
            <img src="http://quote.stock.hexun.com/WebPic/SH/Min/000012_msn.gif" width="190"
                id="indexpic">
        </div></div></td>
                </tr>
    </table>