如何在asp.net c#中显示和隐藏mouseover和mouseout事件的标签
How to display and hide a label on mouseover and mouseout event in asp.net c#
Wnen我的鼠标在Label1上,我想在它附近显示Label2。然后,当我的鼠标离开Label1时,我想隐藏Label2。我尝试使用以下代码。我的javascript很差。
<script language="javascript" type="text/javascript">
function LabelHover()
{
document.getElementById('Label1').style.display = 'inherit';
}
function Labelleave()
{
document.getElementById("Label1").style.display='none';
}
</script>
</head>
<body>
<asp:Label ID="Label1" runat="server" Text="Hello" Height="120" Width= "120" ForeColor="Brown" style=" left:220px; border:groove; top:15px " >
</asp:Label>
<asp:Label ID="Label2" runat="server" Text="Disclaimer" Height="17" Width= "100" ForeColor="Brown" onmouseover="LabelHover()" onmouseout="Labelleave()" style=" left:220px; " >
</asp:Label>
这是我的javascript:
<script language="javascript" type="text/javascript">
function LabelHover() {
document.getElementById('<%= Label1.ClientID%>').style.display = 'inherit';
}
function Labelleave() {
document.getElementById('<%= Label1.ClientID%>').style.display = 'none';
}
</script>
和标记:
<asp:Label ID="Label1" runat="server" Text="Hello" Height="120" Width= "120" ForeColor="Brown" style=" left:220px; border:groove; top:15px; float:left; " >
</asp:Label>
<asp:Label ID="Label2" runat="server" Text="Disclaimer" Height="17" Width= "100" ForeColor="Brown" onmouseover="LabelHover()" onmouseout="Labelleave()" style=" left:220px;float:left; " >
</asp:Label>
由于要显示或隐藏Label2依赖于Label1,因此必须在Label1而不是Label2 处添加onmouseover()和onmouseout()
<asp:Label ID="Label1" runat="server" Text="Hello" Height="120" Width= "120" onmouseover="LabelHover()" onmouseout="Labelleave()" ForeColor="Brown" style=" left:220px; border:groove; top:15px " >
</asp:Label>
<asp:Label ID="Label2" runat="server" Text="Disclaimer" Height="17" Width= "100" ForeColor="Brown" style=" left:220px; " >
</asp:Label>
Javascript:
<script language="javascript" type="text/javascript">
function LabelHover() {
document.getElementById('Label2').style.visibility = 'visible';
}
function Labelleave() {
document.getElementById('Label2').style.visibility = 'hidden';
}
</script>
相关文章:
- 音频控件在mouseover上显示,在mouseout上淡出
- 在单击任何位置时隐藏元素,而不检查每次DOM单击
- 显示5秒后隐藏潜水
- 在不使用JQuery的情况下隐藏DOM中的选定元素
- 剑道UI内联编辑:如何在点击其他按钮时隐藏按钮
- 浮动页脚栏-使用Bootstrap隐藏
- 在jquery中为显示/隐藏设置cookie
- 单击按钮后如何逐个调用分区,上一个分区将隐藏
- 从var向代码隐藏函数传递值
- Image赢得't隐藏在滚动jQuery上
- 具有rowGrouping的数据表无法隐藏列
- Jquery隐藏未触发
- JavaScript 检查隐藏字段中的值并将其设置为隐藏字段值
- 分部隐藏在jquery中不起作用
- 点击后隐藏潜水?(但如果Div是一面旗帜呢?)
- javascript.点击隐藏事件故障
- 禁用(而不是隐藏)浏览器滚动条
- mouseOver上的隐藏图像问题
- 在mouseover上显示元素在mouseleave上隐藏
- 如何在asp.net c#中显示和隐藏mouseover和mouseout事件的标签