Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- english -
- Hello, could anyone of you help me ???
- I'm trying to make horizontal checkbox 4, with the div hidden, and show the div only when I click, so I have.
- 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.
- pt-br-
- Olá, será que alguém de vocês poderia me ajudar ???
- estou tentando fazer 4 checkbox horizontal, com as div oculta, e mostrar as div só quando clicar, ate ai eu consegui.
- 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.
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Documento sem título</title>
- <!-- precisa do arquivo a baixo, baixado. -->
- <script src="jquery-1.3.2.min.js"></script>
- <script src="teste/jquery-1.3.2.min.js"></script>
- <style>
- /* ESCONDE TODAS AS DIVS */
- .divs{display:none;}
- </style>
- <script>
- $(document).ready(function() {
- // QUANDO CHECKBOX É CHECADO
- $('.checkbox').click(function() {
- // ESCONDE TODAS AS DIVS
- $('.divs').hide();
- // PEGA CADA CHECKBOX
- $('.checkbox:checked').each(function() {
- // PEGA O VALOR DO CHECKBOX, E ADICIONA AO D DA DIV
- // D1, D2, ....
- $('#d'+$(this).val()).show();
- // FIM DO EACH
- });
- // FIM DO CLICK
- });
- // FIM DO READY
- });
- </script>
- <form>
- 1 <input type="checkbox" class="checkbox" value="1"><br />
- 2 <input type="checkbox" class="checkbox" value="2"><br />
- 3 <input type="checkbox" class="checkbox" value="3"><br />
- 4 <input type="checkbox" class="checkbox" value="4"><br />
- </form>
- <div class="divs" id="d1">div1</div>
- <div class="divs" id="d2">div2</div>
- <div class="divs" id="d3">div3</div>
- <div class="divs" id="d4">div4</div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement