简体   繁体   English

使用JQuery隐藏asp.net页上的所有面板

[英]Hide all panels on asp.net page using JQuery

There are number of panels on the asp.net page. 在asp.net页上有许多面板。 Panels can be hidden by giving their id in JQuery. 通过在JQuery中提供其ID,可以隐藏面板。

Example: 例:

$('#pnlEmployee').hide(); 

Is there any way to hide all the panels in one go without giving their ids? 有没有一种方法可以一次性隐藏所有面板而不提供其ID?

ie They following JQuery can be used to clear all text box contents; 即它们后面的JQuery可用于清除所有文本框内容;

$('input[type=text]').val('');

Is there any way of doing it for hidding all the panels? 有什么方法可以隐藏所有面板吗?

Here is the example HTML code; 这是示例HTML代码;

<asp:Panel ID="pnlEmployee" runat="server">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
</table>
</asp:Panel>

<asp:Panel ID="pnlDetails" runat="server">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
</table>
</asp:Panel>

Your panels reveal a common pattern - they all have pnl part in their ID. 您的面板显示出一种常见的模式-它们的ID中都有pnl部分。 Since panels are rendered as div , you can use this fact to build a selector: 由于面板渲染为div ,因此您可以使用以下事实来构建选择器:

$("div[id*='pnl']").hide();

Try as below: 尝试如下:

JS: JS:

document.getElementById('Panel1').style.display = 'none';

ASP.NET ASP.NET

<asp:Panel ID="Panel1" runat="server">
   <asp:Label ID="Label1" runat="server">Asp panel content</asp:Label>        
</asp:Panel>

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

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