使用JavaScript或C#.net将鼠标悬停在事件上 [英] mouse over event using JavaScript Or C#.net

查看:55
本文介绍了使用JavaScript或C#.net将鼠标悬停在事件上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在图像上进行鼠标悬停时,我想显示一些文本,如何使用javascript或C#.Net代码可能出现问题


问候
venkat

when ever I do mouseover on image ,I want display some text how it possible using javascript or C#.Net code Problematically


Regards
venkat

推荐答案

您实际上需要两个事件,onmouseover和onmouseout.当鼠标指针在图像上时,onmouseover将使您显示文本,而当鼠标指针不在图像上时,onmouseout事件将隐藏文本.为了进一步说明,让我向您展示一些代码.

You actually need 2 events for this one, the onmouseover and onmouseout. The onmouseover will let you display text when the mouse pointer is on the image, while the onmouseout event will hide the text when your mouse pointer is out of the image. To illustrate further, let me show you some code.

<html>
<head>
<script type="text/javascript">
function mouseOver()
{
//innerHTML property for IE, value property for other browsers
document.getElementById("lbl").innerHTML ="mouse over";
}
function mouseOut()
{
//innerHTML property for IE, value property for other browsers
document.getElementById("lbl").innerHTML ="mouse out";
}
</script>
</head>
<body>
<img border="1" alt="My Image" src="image.gif" id="img1" onmouseover="mouseOver()"  önmouseout="mouseOut()"/>
</img></body>
</html> 



如您所见,我已将image标记的两个事件指向触发事件时将执行的2个JavaScript方法.



As you can see, I have pointed the two events of the image tag to the 2 JavaScript methods that will execute when the event has been fired.


这篇关于使用JavaScript或C#.net将鼠标悬停在事件上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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