un elemento de la lista de casillas de verificación marcada debe habilitar un div y viceversa

I have a div tag with following checkbox list

  <div id="checkboxDiv" class="checkboxDivclass">
                <table id="checkBoxList" runat="server">
                    <tbody>
                <tr>
                          <td><input id="checkBoxList_0" type="checkbox" name="checkBoxList0"></td>
                          <td><input id="checkBoxList_1" type="checkbox" name="checkBoxList1"></td>                             
                </tr>
                    </tbody>
            </table>
            </div>

And a rssDiv with the following HTML

    <div id="rssDiv" runat="server" class="rssDivClass">
      Somecontent here
    </div>

So when you select at least one checkbox item select then rssDiv should be displayed, if none is checked then it should be hide.

Please help me, I need to solve this with Jquery.

Gracias

preguntado el 10 de marzo de 12 a las 04:03

3 Respuestas

Simplemente puede hacer:

$('#checkboxDiv #checkBoxList input:checkbox').click(function(){
   if($('#checkboxDiv #checkBoxList input:checked').size() > 0)
        $('div#rssDiv').show();
   else
        $('div#rssDiv').hide();
});

respondido 10 mar '12, 04:03

from below code you will get a name of checkBoxList which is checked.

$("#checkBoxList").children("input:checked").map(function() {
return this.name;
});

after you can display rssDiv based on that.

Muchas Gracias

respondido 10 mar '12, 04:03

Try this jquery code.

 $(document).ready(function()
         $('input:checkbox').click(function() {
        if($('#checkBoxList_0').is(':checked')==true)
        {
             $('div#rssDiv').show();
        }
        else
        {
             $('div#rssDiv').hide();
        }
      });
});

respondido 10 mar '12, 04:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.