Question

Voici mon code HTML:

<tr>
                        <td colspan="2" class="borderBottomCell">
                          <div class="benefitInfo" style="WIDTH: 99%! important;">
                            <asp:DropDownList runat="server" ID="ddlbc1"  />
                            <asp:Label runat="server" ID="lblbc1" />
                            <asp:Literal runat="server" ID="spcbc1" Text="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />
                            <asp:Label runat="server" ID="bd1" />
                            <asp:HiddenField runat="server" ID="hdnbc1"  /> 
                          </div>
                        </td>
                        <td class="borderBottomCell2">
                            <asp:TextBox runat="server" ID="amt1" CssClass="transparentTextBox amount" Width="60px" Columns="9" />
                        </td>
                        <td class="borderBottomCell2">
                            <asp:TextBox runat="server" ID="int1" CssClass="transparentTextBox" Width="60px" Columns="9" />

                        </td>
                    </tr>

J'essaie d'obtenir une référence à la zone de texte amt1. J'ai besoin de cela en boucle car il ne s'agit que d'une rangée d'un tableau. Je dois parcourir les listes déroulantes et si selectedIndex est supérieur à zéro (> 0). La zone de texte du montant doit comporter un montant supérieur à zéro (> 0). J'implémenterai la validation dataType à l'avenir, je n'ai actuellement besoin que de savoir comment accéder à la zone de texte correspondante avec ma boucle.

J'ai ce code jusqu'à présent ....

$(".benefitInfo select").each(function() {
    var ddl = $(this);

});

Quel est le meilleur moyen d'y parvenir? Devrais-je obtenir une référence à parent (). Parent (). Next (). Find (": input") ... Ou quelque chose de similaire peut-être?

Était-ce utile?

La solution

Cela devrait fonctionner:

$(".benefitInfo select").each(function() {
    var ddl = $(this);
    var amtTxt = ddl.closest('tr').find('.amount');
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top