简体   繁体   English

在相似细分中选择相似元素

[英]Selecting similar elements in similar sub div's

I'm trying to select an array of elements using JQuery that are in separate sub div's. 我正在尝试使用单独的子div中的JQuery选择元素的数组。

ie

<div class="panelWrap">
                    <div id="dvStage1" class="milestoneWrap" runat="server">
                        <div class="grid_1 detailsWrap">
                            <asp:TextBox ID="detailsStage1"></asp:TextBox>
                        </div>
                        <div class="grid_1 dateWrap">
                            <asp:TextBox ID="completedDateStage1"></asp:TextBox>
                        </div>
                    </div>
                    <div id="dvStage2" class="milestoneWrap" runat="server">
                        <div class="grid_1 detailsWrap">
                            <asp:TextBox ID="detailsStage2"></asp:TextBox>
                        </div>
                        <div class="grid_1 dateWrap">
                            <asp:TextBox ID="completedDateStage2"></asp:TextBox>
                        </div>
                    </div>
                    <div id="dvStage3" class="milestoneWrap hidden" runat="server">
                        <div class="grid_1 detailsWrap">
                            <asp:TextBox ID="detailsStage3"></asp:TextBox>
                        </div>
                        <div class="grid_1 dateWrap">
                            <asp:TextBox ID="completedDateStage3"></asp:TextBox>
                        </div>
                    </div>
                </div>

etc.. 等等..

At run time, some of the stages are hidden depending on how many are needed. 在运行时,根据需要的数量,某些阶段会被隐藏。

I want to select the dateWrap div or the text box within it for each stage, but excluding those that have "hidden" in the class name. 我想为每个阶段选择dateWrap div或其中的文本框,但要排除那些在类名中具有“隐藏”的对象。

eg selecting completedDateStage1 and completedDateStage2, but excluding completedDateStage3, as it's parent div is hidden. 例如,选择completedDateStage1和completedDateStage2,但不包括completedDateStage3,因为它的父div被隐藏了。

I've toyed around with the :not and :contains selectors, but no luck so far. 我玩弄了:not和:contains选择器,但是到目前为止还没有运气。

Any advice would be great. 任何建议都很好。

Maybe with this : $(".milestoneWrap:not(.hidden)").find(".dateWrap") 也许与此: $(".milestoneWrap:not(.hidden)").find(".dateWrap")

(working exampe : http://jsfiddle.net/TCHdevlp/yFNpK/1/ ) (工作示例: http : //jsfiddle.net/TCHdevlp/yFNpK/1/

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

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