I have a table inside a table. The basic structure is as follows
<input type="checkbox" name="CheckAll" id="CheckAll"/> <b>Click to select all Option Values</b>
<table class="Parent">
<tr>
<td><input type="checkbox" id="Parent">Parent1</td>
<td><table class="Children">
<tr><td><input type="checkbox" id="Child">Child1</td></tr>
<tr><td><input type="checkbox" id="Child">Child2</td></tr>
<tr><td><input type="checkbox" id="Child">Child3</td></tr>
<td>
</tr>
<tr>
<td><input type="checkbox" id="Parent">Parent2</td>
<td><table class="Children">
<tr><td><input type="checkbox" id="Child">Child1</td></tr>
<tr><td><input type="checkbox" id="Child">Child2</td></tr>
<td>
</tr>
When I click Check All, the checkbox above the table, I want all the Check boxes to be selected or deselected. Which I did with the following
$(document).ready(function () {
$("#CheckAll").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
});
Now I am trying to select all Children when one of the parent is selected. Suppose I do not have access to the parent id in my View. How can I access only the table that is adjacent to the checkbox that is being changed?
idI can give is the name of the parent itself.Parentand you can selector by.Parent[type=checkbox]