jquery - How can I hide a row of the table(MyTable) by a row id when I check checkbox(MyCheckbox) and show the row when the checkbox is unchecked -


When I check the check box (MyCheckbox) and show the row, How can I hide the row when the MyCheckbox is not used with Jquery?

  $ (": checkbox") .click (function () {var index = $ ("# MyCheckboxes: checkbox"). Index ($ (this)); $ ("# myTable tr"). Eq (index) .toggle ();}); & Lt; Table id = "myTable" & gt; & Lt; Tr & gt; & Lt; Td> Line 1 & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> Line 2 & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> Line 3 & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> Line 4 & lt; / Td> & Lt; / Tr & gt; & Lt; / Table & gt; & Lt; Table id = "myCheckboxes" & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input type = "checkbox" /> Checkbox 1 & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input type = "checkbox" /> Checkbox 2 & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input type = "checkbox" /> Checkbox 3 & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td> & Lt; Input type = "checkbox" /> Checkbox 4 & lt; / Td> & Lt; / Tr & gt; & Lt; / Table & gt;   

Online examples:



Comments