Javascript 显示或隐藏子div

Javascript 显示或隐藏子div,javascript,asp.net,Javascript,Asp.net,嗨,伙计们,有人能告诉我如何隐藏另一个div标签中的div吗? 我正在使用javascript…这是我目前所拥有的: function hideShowQuestionDivs() { var drpQuestions = document.getElementById('<%= drpNumQuestions.ClientID %>'); if (drpQuestions.selectedIndex == 0) { document.getElem

嗨,伙计们,有人能告诉我如何隐藏另一个div标签中的div吗? 我正在使用javascript…这是我目前所拥有的:

function hideShowQuestionDivs() {

    var drpQuestions = document.getElementById('<%= drpNumQuestions.ClientID %>');
    if (drpQuestions.selectedIndex == 0) {
        document.getElementById('one').parentNode.removeChild;
        document.getElementById('2').style.display = 'none';
        document.getElementById('3').style.display = 'none';
    }

    if (drpQuestions.selectedIndex == 1) {
        document.getElementById('2').style.display = 'none';
        document.getElementById('3').style.display = 'none';
    }

    if (drpQuestions.selectedIndex == 2) {
        document.getElementById('3').style.display = 'none';
    }
}
函数hideshowsquestiondivs(){
var drpQuestions=document.getElementById(“”);
如果(drpQuestions.selectedIndex==0){
document.getElementById('one').parentNode.removeChild;
document.getElementById('2').style.display='none';
document.getElementById('3').style.display='none';
}
如果(drpQuestions.selectedIndex==1){
document.getElementById('2').style.display='none';
document.getElementById('3').style.display='none';
}
如果(drpQuestions.selectedIndex==2){
document.getElementById('3').style.display='none';
}
}
这是HTML的一个示例:

  <asp:UpdatePanel ID="upEntryScreen" runat="server">
        <ContentTemplate>
            <div id="divEntryMain">
                <br class="style13" />
                <span class="style13">
                <tr>
                    <th>
                    </th>
                </tr>
                </span>
                <asp:Label ID="lblCampaignType" runat="server" CssClass="style13" 
                    Text="Campaign Type"></asp:Label>
                <span class="style13">
                </th>
                <th>
                </th>
                </span>
                <uc:ROSDropDown ID="drpCampaignType" runat="server" CssClass="style13" 
                    onchange="javascript:hideOrShowBuilderDiv()" Width="140">
                </uc:ROSDropDown>
                <span class="style13">
                </th>
                </tr>
                <tr>
                    <th>
                    </th>
                </tr>
                </span>
                <asp:Label ID="lblCampaignDockTemplate" runat="server" CssClass="style13" 
                    Text="Campaign Docket Template"></asp:Label>
                <span class="style13">
                </th>
                <th>
                </th>
                </span>
                <uc:ROSDropDown ID="drpListCampaignDocketTemplate" runat="server" 
                    CssClass="style13" onchange="javascript:hideOrShowBuilderDiv()" Width="100">
                </uc:ROSDropDown>
                <span class="style13">
                </th>
                </tr>
                <tr>
                    <th>
                    </th>
                </tr>
                </span>
                <asp:Button ID="btnCancel" runat="server" CssClass="style11" Text="Cancel" 
                    Width="100" />
                <asp:Button ID="btnCreate" runat="server" CssClass="style11" Text="Create" 
                    Width="100" />
                <span class="style13">
                </th>
                </tr>
                </span>
            </div>
            <div id="divBuilderMain">
                <table>
                    <tr>
                        <td class="style4" valign="top">
                            <div id="left">
                                <table>
                                    <tr>
                                        <th class="style6">
                                            &nbsp;</th>
                                        <th class="style7">
                                            &nbsp;</th>
                                    </tr>
                                    <tr>
                                        <th class="style6">
                                            <asp:Label ID="lblCampStatus" runat="server" CssClass="style13" Font-Size="7pt" 
                                                Text="Set Campaign Status"></asp:Label>
                                        </th>
                                        <th class="style7">
                                            <asp:RadioButtonList ID="rdbCampStatus" runat="server" CellPadding="0" 
                                                CellSpacing="0" Font-Size="7pt" Height="16px" 
                                                Style="margin-left: 33px; text-align: justify;">
                                                <asp:ListItem>Inactive</asp:ListItem>
                                                <asp:ListItem>Active</asp:ListItem>
                                            </asp:RadioButtonList>
                                        </th>
                                    </tr>
                                    <tr>
                                        <th class="style6">
                                            <asp:Label ID="lblCreatedBy" runat="server" CssClass="style13" Font-Size="7pt" 
                                                Text="Created By"></asp:Label>
                                        </th>
                                        <th>
                                            <asp:TextBox ID="txtCreatedBy" runat="server" CssClass="style13" 
                                                Font-Size="7pt" Width="100"></asp:TextBox>
                                        </th>
                                    </tr>
                                    </div>
    <div id="one">
    <tr>
                                        <th class="style6">
                                            <asp:Label ID="lblCampType" runat="server" CssClass="style13" Font-Size="7pt" 
                                                Text="Campaign Type"></asp:Label>
                                        </th>
                                        <th>
                                            <uc:ROSDropDown ID="drpCampType" runat="server" CssClass="style13" 
                                                Font-Size="7pt" Width="100">
                                            </uc:ROSDropDown>
                                        </th>
                                    </tr>
                                    <tr>
                                        <th class="style6">
                                            <asp:Label ID="lblCampDockTemplate" runat="server" CssClass="style13" 
                                                Font-Size="7pt" Text="Campaign Dock Template"></asp:Label>
                                        </th>
                                        <th>
                                            <uc:ROSDropDown ID="drpCampDockTemplate" runat="server" CssClass="style13" 
                                                Font-Size="7pt" Width="100">
                                            </uc:ROSDropDown>
                                        </th>
                                    </tr>
                                    <tr>
                                        <th class="style19" colspan="2">
                                            &nbsp;</th>
                                    </tr>
                                    <tr>
                                        <th class="style19" colspan="2">
                                            Store/Docket Fields
                                        </th>
                                    </tr>
                                    <tr>
                                        <th class="style6">
                                            <asp:Label ID="lblStoreDescription" runat="server" CssClass="style13" 
                                                Font-Size="7pt" Text="Store Description"></asp:Label>
                                        </th>
                                        <th>
                                            <asp:TextBox ID="txtStoreDescription" runat="server" CssClass="style13" 
                                                Font-Size="7pt" Width="100"></asp:TextBox>
                                        </th>
                                    </tr>
    </div>


这就是隐藏子div的方法

$('#parentDivID > #childDivID').hide();
$('#parentDivID > #childDivID').show();
这就是如何显示子div

$('#parentDivID > #childDivID').hide();
$('#parentDivID > #childDivID').show();
确保页面中包含jquery脚本


基本上,您需要选择需要隐藏/显示的元素,在jquery中,您可以使用CSS选择器来实现这一点。然后在它们上调用.show()或.hide()方法

你也应该发布一些HTML。我已经编辑以显示HTML。.谢谢你应该学习JQuery():)请发布生成的代码?