Selecting a Row When Checkbox in a TD is Checked?

Selecting a Row When Checkbox in a TD is Checked?

I have a table, listing foods, and each row in the table has a few
checkboxes the user can check to show if they eat the food for
breakfast, lunch, dinner, etc. For example:

<td width="8%">
                <center>
                    <input type="checkbox" name="Dinner_id_5"
value="9003" class="Dinner"><br>
                    Dinner
                </center>
            </td>


I want to be able to hide and show rows based on whether the checkbox
is checked. It's easy to hide all the rows, using this:

$(".food_planner tbody tr").hide();


Now I just want to show the rows that have, say, checkboxes of
class="Dinner" checked. I'm trying this:

$(".Dinner input:checked").parent().parent().show();


...but it doesn't seem to work yet. What's the correct way to do this?

Thanks very much in advance to all for any info.
    • Topic Participants

    • vikr