鼠标悬停在标签上时如何显示/隐藏文本框 [英] How to show / hide a textbox when mousehovers on a label
本文介绍了鼠标悬停在标签上时如何显示/隐藏文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我将鼠标悬停在标签上时,我想让文本框可见。同时我也想在鼠标离开标签时隐藏它。我尝试使用以下代码来显示一些文本。多数民众赞成。
< script language = javascript type = text / javascript >
函数LabelHover(){
var text =event;
document.getElementById(Label1)。innerHTML = text;
}
函数Labelleave(){
var text =Hello;
document.getElementById(Label1)。innerHTML = text;
}
< / script < span class =code-keyword>>
< / head >
< body >
< asp:标签 ID = Label1 runat = server < span class =code-attribute> 文本 = Hello ForeColor = 布朗 onmouseover < span class =code-keyword> = LabelHover() onmouseleave = Labelleave()
style = left:120px; border:groove; >
< < span class =code-leadattribute> / asp:Label >
< / body >
任何人都可以帮助我吗?我的java很差。这是用于web开发。
解决方案
< blockquote>你不小心覆盖/删除了Label1的内容/行为。
你必须在另一个控件上显示,例如:DIV
< html >
< head >
< title > < / title >
< script type = text / javascript >
function mouseOver(){
document .getElementById( divTextBox)。innerHTML = Cursor In;
}
function mouseLeave(){
document .getElementById( divTextBox)。innerHTML = 光标输出;
}
< / 脚本 >
< / head >
< body >
< asp:label id = Label1 onmouseover = mouseOver() onmouseout = mouseLeave() text = 这是Label1 runat = server < span class =code-attribute> xmlns:asp = #unknown < span class =code-keyword>> < / asp:label < span class =code-keyword>>
< div id = < span class =code-keyword> divTextBox > < / div >
< / body >
< / html >
你可以用jquery来做:
('#Label1')。mouseover(function( ){
I want to make visible a textbox when I bring the mouse over a label. At the same time I also want to hide it when my mouse leaves that label. I tried with the following code to show some text. Thats all.
<script language="javascript" type="text/javascript">
function LabelHover() {
var text = "event";
document.getElementById("Label1").innerHTML = text;
}
function Labelleave() {
var text = "Hello";
document.getElementById("Label1").innerHTML = text;
}
</script>
</head>
<body>
<asp:Label ID="Label1" runat="server" Text="Hello" ForeColor="Brown" onmouseover="LabelHover()" onmouseleave="Labelleave()"
style=" left:120px; border:groove;">
</asp:Label>
</body>
Can any one help me out? I am poor in java. This is for web development.
解决方案
You have accidentally overwrite/erase the content/behaviour of "Label1".
You have to display on another control, for example: DIV
<html> <head> <title></title> <script type="text/javascript"> function mouseOver() { document.getElementById("divTextBox").innerHTML = "Cursor In"; } function mouseLeave() { document.getElementById("divTextBox").innerHTML = "Cursor Out"; } </script> </head> <body> <asp:label id="Label1" onmouseover="mouseOver()" onmouseout="mouseLeave()" text="This is Label1" runat="server" xmlns:asp="#unknown"></asp:label> <div id="divTextBox"></div> </body> </html>
you can use jquery to do it :
('#Label1').mouseover(function(){
这篇关于鼠标悬停在标签上时如何显示/隐藏文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文