javascript 如何在javascript中隐藏面板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5246373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 16:31:23  来源:igfitidea点击:

how to hide a panel in javascript

javascriptasp.net

提问by Sheikh Rahat Ali

What is the best approach to show and hide an asp panel which is containing other controls like textbox and label controls

显示和隐藏包含其他控件(如文本框和标签控件)的 asp 面板的最佳方法是什么

回答by Guillaume86

Using jQuery, you can just switch visibilty:

使用 jQuery,您可以切换可见性:

$('#<%= YourPanel.ClientID %>').hide();
$('#<%= YourPanel.ClientID %>').show();

Edit: jQuery is probably overkill just to hide/show, but if you plan to add more functionality client side, you should consider using it ;)

编辑:jQuery 可能只是为了隐藏/显示而矫枉过正,但是如果您打算在客户端添加更多功能,则应该考虑使用它;)

回答by Bala R

Can you try

你能试一下吗

document.getElementById( 'Panel1ClientId' ).style.display = 'none'; // to hide

and

document.getElementById( 'Panel1ClientId' ).style.display = 'block'; // to show

?

?