Question

I now have an asp button in a gridview which I can toggle the text from "Add" to "Remove". Now what I would like is either jquery or javascript to loop through all the rows (or inquire all rows) to determine if any buttons have been toggled (they would have text of "Remove" since the default is "Add"). I don't necessarily need to loop through and process anything, I just want to hide a div if no buttons have been toggled to text of "Remove". The user may have toggled the buttons to "Remove" and back to "Add". So I need to know if at least one button text is currently "Remove".

Here is my templated asp button definition:

<asp:TemplateField HeaderText="Prior <br /> Downld" HeaderStyle-ForeColor="White" > 
  <ItemTemplate >
    <asp:Button id="btnBuy" runat="server" OnClientClick="btnBuyToggle(this); return false;" Text="Add" CssClass="buyButton" Visible='<%# Eval("SORD_ShowBuyButton") %>' />
  </ItemTemplate>
<HeaderStyle Width="7%" />
<ItemStyle CssClass="sessionOrderDownloadItems" VerticalAlign="Middle" HorizontalAlign="Center" />
</asp:TemplateField>

Anyway, I am hoping for maybe a jquery selector looking for text = "Remove", but I am not sure how to construct it.

Note: Working result is this:

       if ( $("input[value=Remove]").length == 0 ) {
            $(".divDownloadHeaderClass").show();
            $(".divPurchaseHeaderClass").hide();
          }
        }
Était-ce utile?

La solution

I think this would work:

if ( $("input[value=Remove][type=submit]").length > 0 ) {
    $(".divDownload").hide();
}

Hope it helps!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top