Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js][css] visibility hidden
hondek
post
Post #1





Grupa: Zarejestrowani
Postów: 355
Pomógł: 50
Dołączył: 20.08.2007
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


Chce zrobic chowające się menu, ale nie chce mi sie chowac (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) w style.css mam ustwione visibility: hidden;
  1.  function menu(id) {
  2.      if (document.getElementById(id).style.visibility='hidden') {
  3.          document.getElementById(id).style.visibility='visible';
  4.          document.getElementById(id).style.height='100px';
  5.      }
  6.      else {
  7.          document.getElementById(id).style.visibility='hidden';
  8.          document.getElementById(id).style.height='0px';
  9.          return
  10.      }
  11.  }
  12.  


i html :

  1. <div onclick=" menu('ok') " class="menu">Menu</div>


Menu laduje sie schowane, jak klikne to sie rozwija (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) ale jak klikne ponownie to sie nie zwija... (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Proszę o pomoc, z góry dziekuję.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
nevt
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 595
Pomógł: 282
Dołączył: 24.09.2007
Skąd: Reda, Pomorskie.

Ostrzeżenie: (0%)
-----


Może to bez znaczenia... ale dlaczego return jes tylko w bloku else ? powinien być po całym if , no i brakuje po nim średnika... koże dlatego blok else nie działa?

Pozdrawiam.
Go to the top of the page
+Quote Post
hondek
post
Post #3





Grupa: Zarejestrowani
Postów: 355
Pomógł: 50
Dołączył: 20.08.2007
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


pomyłka (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) return mialo nie być (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) bez tego też się nie chowa:(
Błąd tkwi gdzieś indziej.
Go to the top of the page
+Quote Post
Stalos
post
Post #4





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 28.12.2006

Ostrzeżenie: (0%)
-----


  1. var zmienna_globalna = 1;
  2.  
  3. function menu(id) {
  4. var element = document.getElementById(id);
  5. if (zmienna_globalna == 0){
  6. element.style.visibility='visible';
  7. element.style.height='100px';
  8. zmienna_globalna = 1;
  9. return true;
  10. }
  11. else{
  12. element.style.visibility='visible';
  13. element.style.height='10px';
  14. zmienna_globalna = 0;
  15. return true;
  16.  
  17. }
  18.  
  19. }
  20. </script>
  21. </head>
  22. <div onclick="menu('menu')" id="menu">Menu</div>
  23. document.getElementById('menu').style.background = "red";
  24. </body>
  25.  
  26. </html>


dałem tło czerwone aby widać było jak się zmienia. O to chodziło ?
Go to the top of the page
+Quote Post
hondek
post
Post #5





Grupa: Zarejestrowani
Postów: 355
Pomógł: 50
Dołączył: 20.08.2007
Skąd: Częstochowa

Ostrzeżenie: (0%)
-----


Tak, o to (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Dziękuje bardzo!
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 04:00