当前位置:编程学习 > C#/ASP.NET >>

急求俩个图片当鼠标放上去时图片就能转换 谢谢在线等

急求俩个图片当鼠标放上去时图片就能转换 谢谢在线等 --------------------编程问答-------------------- Control.OnMouseMovie --------------------编程问答-------------------- 或
Control.OnMouseEnter --------------------编程问答-------------------- 给个完整的列子吧 本人新手 谢谢 --------------------编程问答-------------------- 用JS做吧,这是我知道的方法,去网上一收就行了,那上面有 --------------------编程问答-------------------- 写成一个循环,循环读取所有图片,把图片路径赋值给控件,当然是在OnMouseMovie时调用方法 --------------------编程问答-------------------- 谢谢那我去收索下 要是没找到还的麻烦你  --------------------编程问答-------------------- 谁能给写下源码 小弟在此谢谢了 我是真不会写了 --------------------编程问答-------------------- 用javascript可以实现
大概代码如下:
<script type="text/javascript">
function mouseOver()
{
document.getElementById('b1').src ="/i/eg_mouse.jpg"
}
function mouseOut()
{
document.getElementById('b1').src ="/i/eg_mouse2.jpg"
}
</script>


调用方法如下:

<a href="#" 
onmouseover="mouseOver()" onmouseout="mouseOut()">
<img alt="Visit W3School!" src="/i/eg_mouse2.jpg" id="b1" />
</a>
--------------------编程问答-------------------- 我试过了 不怎么好用啊 是不是还需要写别的啊  --------------------编程问答-------------------- 8楼写的没有问题,不过楼主也不要照搬啊,你要根据你的实际情况来设置两个图片的地址。 --------------------编程问答-------------------- </head>
<body>
    
<a href="#" 
onmouseover="mouseOver()" onmouseout="mouseOut()"> 
<img alt="Visit W3School!" src="~/图片/tab_g3_bg.jpg" id="ImageButton2" /> 
</a> 
    

    </div>
        <table>
            <tr>
                <td style="width: 169px; height: 103px">
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/图片/tab_w1_bg.jpg" />
                    <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/图片/tab_g3_bg.jpg" />
                   
            </tr>
        </table>
        <script type="text/javascript"> 
function mouseOver() 

document.getElementById('ImageButton2').src ="~/图片/tab_w1_bg.jpg" 

function mouseOut() 

document.getElementById('ImageButton2').src ="~/图片/tab_g3_bg.jpg"

</script> 



    
    </form>
    
</body>
</html>
你帮我看看这么写对么? --------------------编程问答-------------------- </head>
<body>
    
<a href="#" 
onmouseover="mouseOver()" onmouseout="mouseOut()"> 
<img alt="Visit W3School!" src="~/图片/tab_g3_bg.jpg" id="ImageButton" /> 
</a> 
    

    </div>
        <table>
            <tr>
                <td style="width: 169px; height: 103px">
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/图片/tab_w1_bg.jpg" />
                    <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/图片/tab_g3_bg.jpg" />
                   
            </tr>
        </table>
        <script type="text/javascript"> 
function mouseOver() 

document.getElementById('ImageButton2').src ="~/图片/tab_w1_bg.jpg" 

function mouseOut() 

document.getElementById('ImageButton2').src ="~/图片/tab_g3_bg.jpg"

</script> 



    
    </form>
    
</body>
</html>
是这么写么? <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/图片/tab_w1_bg.jpg" />
                    <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/图片/tab_g3_bg.jpg" />
                   
这是我上传的图片
--------------------编程问答--------------------
function mouseOver() 

document.getElementById('ImageButton2').src ="~/图片/tab_w1_bg.jpg" 

function mouseOut() 

document.getElementById('ImageButton2').src ="~/图片/tab_g3_bg.jpg" 

不是这么写的,在js里不是支持"~/"这种路径的,你这里只能写实际的路径,相对的或绝对的都行。 --------------------编程问答-------------------- 谢谢 好 用了  但为什么刚开始时不是显示我的图片而是显示他---"Visit W3School!" --------------------编程问答-------------------- 怎么能让上来就是我的图片
--------------------编程问答-------------------- <a href="#" 
onmouseover="mouseOver()" onmouseout="mouseOut()"> 
<img alt="Visit W3School!" src="~/图片/tab_g3_bg.jpg" id="ImageButton" /> 
</a> 


这里的路径改了没有?
应该是这样吧

<a href="#" 
onmouseover="mouseOver()" onmouseout="mouseOut()"> 
<img alt="Visit W3School!" src="../图片/tab_g3_bg.jpg" id="ImageButton" /> 
</a> 
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,