通过文本框的onmouseover事件使标签可见 [英] Make a label visible with onmouseover event for the text box

查看:63
本文介绍了通过文本框的onmouseover事件使标签可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


当鼠标悬停在文本框上方时,我想使标签可见,而在文本框外,鼠标上的标签不可见.我该怎么办?

谢谢

Hi,
I want to make a label visible when the mouse is over atextbox and invisible the label on mouse out of the text box. How can I do it?

Thank you

推荐答案

尝试一下
function LabelShow() {
var element = document.getElementById(''<%=lbl.ClientID %>'');
element.style.display = ''block'';
}
function LabelHide() {
var element = document.getElementById(''<%=lbl.ClientID %>'');
element.style.display = ''none'';
}

<asp:textbox id="txt" runat="server" onmouseover="LabelShow();" onmouseout="LabelHide();" xmlns:asp="#unknown"></asp:textbox>
<asp:label id="lbl" runat="server" text="text" xmlns:asp="#unknown">
</asp:label>


请检查以下代码:

Please check the following code:

<script language="javascript" type="text/javascript">
    function onover()
    {
       // alert("over");
        document.getElementById('<%=Label1.ClientID%>').style.display="inline";
    }
    function onout()
    {
        //alert("out");
        document.getElementById('<%=Label1.ClientID%>').style.display="none";
    }

    </script>





<form id="form1" runat="server">
           <asp:Label ID="Label1" runat="server" Text="show"></asp:Label>
           <asp:TextBox ID="TextBox1" runat="server" onmouseover="javascript:onover();" onmouseout="javascript:onout();"></asp:TextBox>
   </form>




根据您的要求完美工作.

请检查并告知我.

如果找到答案,则将其标记为解决方案,以便其他人可以参考该解决方案.

谢谢
Ashish




Working perfectly as per your requirement.

Please check and let me know.

mark it solution if you got your answer, so that other can refer the solution.

Thanks
Ashish


试图实现它,似乎可以正常工作.这是此内容的aspx标记:

Tried to implement it and it seems to be working. here is the aspx markup for this:

<asp:TextBox ID="TextBox1" runat="server" onfocus="showLabel()" onblur="hidelabel()"

                onmouseover="showLabel()" onmouseout="hidelabel()">

            </asp:TextBox>
            <asp:Label ID="Label1" runat="server" Text="Label" Style="visibility: hidden;"></asp:Label>




这是JS函数




and here is the JS function

function showLabel()
    {
        document.getElementById('Label1').style.visibility = "Visible";
    }

    function hidelabel()
    {
        document.getElementById('Label1').style.visibility = "hidden";
    }


这篇关于通过文本框的onmouseover事件使标签可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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