ninini.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <title>prueba</title>
  5. </head>
  6. <body>
  7. <div id='parent'>
  8. <div id=texto1 style="display: block;">
  9. holaaa soy main q onda
  10. <div>
  11. peo
  12. </div>
  13. </div>
  14. <div id=texto2 style="display: none;">
  15. sexooooooooooo
  16. <div>caca</div>
  17. </div>
  18. </div>
  19. <input onclick="change()" type="button">reemplaza</input>
  20. <script>
  21. function change() // no ';' here
  22. {
  23. var parent = document.getElementById('parent');
  24. var children = parent.childNodes;
  25. console.log(children);
  26. console.log(children[1].id);
  27. console.log(children[3].id);
  28. if(children[1].style.display=="block")
  29. document.getElementById('texto1').style.display = "none";
  30. if(children[3].style.display=="none")
  31. document.getElementById('texto2').style.display = "block";
  32. else if(children[1].style.display=="none")
  33. document.getElementById('texto1').style.display = "block";
  34. if(children[3].style.display=="block")
  35. document.getElementById('texto2').style.display = "none";
  36. }
  37. </script>
  38. </body>
  39. </html>