简体   繁体   English

div可见时如何隐藏标签消息

[英]How to hide a label message when a div becomes visible

I have used a label box to render a " please wait " message when the user clicks " Save " button. 当用户单击“ 保存 ”按钮时,我使用了一个标签框来呈现“ 请稍候 ”消息。 Once the processing gets over, the output gets displayed. 处理结束后,将显示输出。 My goal is to hide the label once the output is displayed. 我的目标是在显示输出后隐藏标签。 How do i achieve this. 我该如何做到这一点。

My code is as follows, 我的代码如下,

 <label id="embedLabel" class="hide" runat="server" visible="false">Please Wait
 </label>  
 <div id="ChannelDIv" class="hide">  
 <textarea id="channellinkCode" runat="server" >  
 </textarea>  
 </div>

My goal is to hide the embedLabel label once the embedLabel is displayed. 我的目标是在显示embedLabel隐藏embedLabel标签。 Am using javascript function on the click event of " save " button to show the embedLabel div. 我在“ 保存 ”按钮的click事件上使用javascript函数来显示embedLabel div。 Any help would be deeply appreciated. 任何帮助将不胜感激。

If you're not using AJAX then when the output gets displayed the whole page will refresh (postback). 如果您不使用AJAX,则在显示输出时,整个页面将刷新 (回发)。 So as long as the default state of your embedLabel is hidden ( display:none or visibility:hidden ) when this happens it will be hidden. 因此,只要您的embedLabel的默认状态为隐藏( display:none or visibility:hidden embedLabel display:none or visibility:hidden ),则在发生这种情况时它将被隐藏。

I can see that you have assigned it the css class hide , but you've also set visible="false" which means it'll never make it to the client at all. 我可以看到您已经为它分配了css类hide ,但是您还设置了visible="false" ,这意味着它永远不会出现在客户端上。

I think you need to remove runat="server" and keep this as a client side label which you only manipulate through JavaScript and CSS (with default hidden) this should solve your problem. 我认为您需要删除runat="server"并将其保留为客户端标签,您只能通过JavaScript和CSS(默认隐藏)进行操作,这应该可以解决您的问题。

You can write code that change css class assigned to message label in javascript onLoad() event handler, so after your page is completly rendered it will hide message label. 您可以在javascript onLoad()事件处理程序中编写更改分配给消息标签的css类的代码,因此在页面完全呈现后它将隐藏消息标签。

edit: 编辑:

<body onload = "hideMessage()" >

<script type="text/javascript" language="JavaScript">

function hideMessage() {
     document.getElementById('embedLabel').style.display = 'none'
} 

</script>

that's what was on my mind when i posted answer, but i agree with Eddy556 that you dont really need it. 当我发布答案时,这就是我的想法,但是我同意Eddy556的意见,您实际上并不需要它。 I missunderstanding yours question initially. 我最初误会了你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM