Asp.net中实现ImageButton的鼠标移人(出)图片变换
前边.Aspx的代码
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/btn1.png" onmouseout="changeback(this)" onmouseover="changeImg(this)"/>
这是脚本JavaScript脚本:
<script type="text/javascript">
function changeImg(btn) //鼠标移入,更换图片
{
btn.src="Images/btn1.png";
}
function changeback(btn) //鼠标移出,换回原来的图片
{
btn.src="Images/btn2.png";
}
</script>
说明:在ImageButton控件中加入两个事件,分别是onmouseover和onmouseout,意思分别是鼠标移入鼠标移出,现在的思路就是当鼠标移入ImageButton控件时通过JavaScript脚本语言变换其背景图片,当鼠标移开的时候再变回来原来的图片。

浙公网安备 33010602011771号