Search Results

Search found 1 results on 1 pages for 'holp'.

Page 1/1 | 1 

  • Checkbox to Show and Hide only for the near DIV

    - by Holp
    Select all options... Then, when the user uncheck "B" and check it again, the "D" parents must be hidden. I have to do it without give then IDs. <html> <head> <title>Form</title> <style> * { font-family: Segoe UI, Verdana; font-size: 10pt; } #total { padding: 10px; position: fixed; top: 10px; left: 500px; width: 150px; height: 100px; } p { margin: 5px; } .grupo { padding: 5px 0 5px 0; } </style> <script src="jquery-1.4.2.min.js" type="text/javascript"></script> </head> <body> <div class="grupo"> <p class="pergunta">A) Lorem ipsum dolor sit amet, nulla nec tortor?</p> <p><label><input type="radio" name="P-1" value="R-1-1" />Sim</label></p> <p><label><input type="radio" name="P-1" value="R-1-2" />Não</label></p> </div> <div class="grupo"> <p class="pergunta"><label><input type="checkbox" name="P-2" value="R-2-3" />B) Donec libero risus, commodo vitae</label></p> <div class="dependente"> <div class="grupo"> <p class="pergunta">C) Lorem ipsum dolor sit amet, nulla nec tortor?</p> <p><label><input type="radio" name="P-3" value="R-3-1" />Morbi in orci</label></p> <p><label><input type="radio" name="P-3" value="R-3-2" />Nulla purus lacus, pulvinar vel</label></p> <p><label><input type="radio" name="P-3" value="R-3-3" />Aliquam ante</label></p> <p><label><input type="radio" name="P-3" value="R-3-4" />Suspendisse scelerisque dui nec velit</label></p> </div> <div class="grupo"> <p class="pergunta"><label><input type="checkbox" name="P-4" value="R-4-5" />D) Donec libero risus, commodo vitae</label></p> <div class="dependente"> <div class="grupo"> <p class="pergunta">E) Lorem ipsum dolor sit amet, nulla nec tortor?</p> <p><label><input type="radio" name="P-5" value="R-5-1" />Morbi in orci</label></p> <p><label><input type="radio" name="P-5" value="R-5-2" />Nulla purus lacus</label></p> </div> </div> </div> </div> </div> <div class="grupo"> <p class="pergunta">F) Lorem ipsum dolor sit amet, nulla nec tortor?</p> <p><label><input type="radio" name="P-6" value="R-6-1" />Morbi in orci</label></p> <p><label><input type="radio" name="P-6" value="R-6-2" />Nulla purus lacus, pulvinar vel</label></p> <p><label><input type="radio" name="P-6" value="R-6-3" />Aliquam ante</label></p> <p><label><input type="radio" name="P-6" value="R-6-4" />Suspendisse scelerisque dui nec velit</label></p> </div> <script type="text/javascript"> $('.dependente').hide(); $(':checkbox').click(function () { var checked = this.checked; $('.dependente:first',$(this).parents('div:first')).css('display',checked ? 'block':'none'); $('.dependente input',$(this).parents('div:first')).attr('checked', false).change(); }); </script> </body> </html>

    Read the article

1