Advertisement
d4v1

exibir/fechar div

Feb 23rd, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.91 KB | None | 0 0
  1. english -
  2. Hello, could anyone of you help me ???
  3. I'm trying to make horizontal checkbox 4, with the div hidden, and show the div only when I click, so I have.
  4. Now I need you to "check" another box, the previous "check" close and show what was "checked" past. can you help me ? Follow the whole code.
  5.  
  6. pt-br-
  7. Olá, será que alguém de vocês poderia me ajudar ???
  8. estou tentando fazer 4 checkbox horizontal, com as div oculta, e mostrar as div só quando clicar, ate ai eu consegui.
  9. Agora preciso que quando "checkar" outra box, a anterior "checkada" feche e mostre a que foi "checkada" por ultimo. podem me ajudar ? segue todo o código.
  10.  
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  15. <title>Documento sem título</title>
  16. <!-- precisa do arquivo a baixo, baixado. -->
  17. <script src="jquery-1.3.2.min.js"></script>
  18. <script src="teste/jquery-1.3.2.min.js"></script>
  19. <style>
  20. /* ESCONDE TODAS AS DIVS */
  21. .divs{display:none;}
  22. </style>
  23. <script>
  24. $(document).ready(function() {
  25. // QUANDO CHECKBOX É CHECADO
  26. $('.checkbox').click(function() {
  27. // ESCONDE TODAS AS DIVS
  28. $('.divs').hide();
  29. // PEGA CADA CHECKBOX
  30. $('.checkbox:checked').each(function() {
  31. // PEGA O VALOR DO CHECKBOX, E ADICIONA AO D DA DIV
  32. // D1, D2, ....
  33. $('#d'+$(this).val()).show();
  34. // FIM DO EACH
  35. });
  36. // FIM DO CLICK
  37. });
  38. // FIM DO READY
  39. });
  40. </script>
  41. <form>
  42. 1 <input type="checkbox" class="checkbox" value="1"><br />
  43. 2 <input type="checkbox" class="checkbox" value="2"><br />
  44. 3 <input type="checkbox" class="checkbox" value="3"><br />
  45. 4 <input type="checkbox" class="checkbox" value="4"><br />
  46. </form>
  47. <div class="divs" id="d1">div1</div>
  48. <div class="divs" id="d2">div2</div>
  49. <div class="divs" id="d3">div3</div>
  50. <div class="divs" id="d4">div4</div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement