How to get the class value of a div that is inside a Repeateritem?

Asked

Viewed 25 times

0

Below the simplified code: Current behavior

1. When Clicking on "divOnoff", the class of the div "divAtivoOnOff" alternates the value at each click between "Onoff on" and "Onoff off". How to store this value in Hiddenonoff?

<asp:Repeater ID="RptModulos" runat="server" OnItemDataBound="RptModulos_ItemDataBound"> 
<ItemTemplate>
    <asp:UpdatePanel ID="UpdModulo" UpdateMode="Conditional" runat="server">
    <ContentTemplate> 
            <div class="OnOff off" id="divAtivoOnOff" runat="server">
            <asp:HiddenField id="HiddenOnOff" runat="server" value="off" ></asp:HiddenField>
            <div class="control-on-off">
                    <span class="lbl-off">INATIVO</span>

                    <div id="divOnoff" class="on-off">
                        <span class="interruptor"></span>
                    </div>
                    <span class="lbl-on">ATIVO</span>
                </div>
            </div>
    </ContentTemplate>
    </asp:UpdatePanel>
</ItemTemplate>
</asp:Repeater> 

1 answer

0

You can use to be triggered when there is a change and then use to set the new value.

$('.divAtivoOnOff').change(function(){
     $('#HiddenOnOff').val(novoValor);    
});

Obs.: I put newValue because I didn’t understand which element exactly will be changed and which attribute. If it is for example in the switch class you can use the following to get the value: $(".switch"). text();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.