javascript中clickevent上的Imagebutton图像更改 [英] Imagebutton image change on clickevent from javascript

查看:60
本文介绍了javascript中clickevent上的Imagebutton图像更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改click上的imagebutton图像,对于图像按钮的每次单击图像交替更改请帮助我吗?

I want to change the imagebutton image on click , for each click image of image button change alternately pls help me?

推荐答案

如果将imagebutton添加到页面并在您喜欢的浏览器中打开页面,然后使用您喜欢的工具调查DOM元素,您将看到ImageButton控件呈现为具有src属性的image类型的html输入元素.这应该给您一些提示.
If you add an imagebutton to a page and open the page in your favorite browser, then using you favorite tool to investigate the DOM elements you will see the ImageButton control is rendered as a html input element of type image with a src attribute. This should give you some hints to start with.


Hope it will help you
<script language=''javascript''>
<!--
function EvImageOverChange(name, direction)
{
switch(direction)
{
case ''in'':
name.src = "image/OverImage.gif";
break;
case ''out'':
name.src = "image/InitialImage.gif";
break;
}
}
//-->
</script>

in the code behind insert this in the Page load method:

if(!IsPostBack)
{
myImageButton.ImageUrl = "image/InitialImage.gif";
myImageButton.Attributes["OnMouseOver"] =
"javascript:EvImageOverChange(this, ''in'');";
myImageButton.Attributes["OnMouseOut"] =
"javascript:EvImageOverChange(this, ''out'');";
}


这篇关于javascript中clickevent上的Imagebutton图像更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆