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

0

Below the simplified code: Current behavior

1. When clicking on "divOnoff", the div class "divOtivoOnOff" toggles the value of each click between "OnOff on" and "OnOff off". How to save 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> 
    
asked by anonymous 14.10.2016 / 15:10

1 answer

0

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

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

Note: I put new Value because I did not understand which element exactly will be changed and which attribute. If for example in the switch class you can use the following to get the value: $ (".switch"). Text ();

    
25.10.2016 / 02:51