I have one checkbox name Select All on which I want to check/uncheck all my checkbox div wise.
As my checkboxes are asp.net controls that is runat=server so I am not getting how to handle it on client side.
This is my code:
<asp:CheckBox onchange="Checkallcheckbox()" ID="chkAll" runat="server" Text="Parent" /> -- parent of all checkboxes.
---------Section 1 -----------
<div id="section1">
<li class="carousel-border">
<asp:CheckBox ID="chkParent1" runat="server" Text="Check All" /> --Parent of below 2 checkboxes
</li>
<li>
<asp:CheckBox ID="chkchild1" runat="server" Text="Child 1" />
</li>
<li>
<asp:CheckBox ID="chkchild2" runat="server" Text="Child 2" />
</li>
</div>
---------Section 2 -----------
<div id="section2">
<li class="carousel-border">
<asp:CheckBox ID="chkParent2" runat="server" Text="Check all" /> --Parent of below 2 checkboxes
</li>
<li>
<asp:CheckBox ID="chkchild3" runat="server" Text="Child 1" />
</li>
<li>
<asp:CheckBox ID="chkchild4" runat="server" Text="Child 2" />
</li>
</div>
function Checkallcheckbox() {
// How to check/uncheck all checkbox on this event
}
$('.checkAll').on('change', function() { $(this).closest('div').find(':checkbox').prop('checked', this.checked);});$('[id^=chkParent]).on('change', function`