Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] Rozwijane menu
o2w5n778
post 20.04.2012, 21:22:39
Post #1





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 10.12.2009

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


Witam!
Jestem na etapie tworzenia rozwijanego menu w JavaScript, niestety napotkałem się na pewien problem. Menu rozwija mi się tylko i wyłącznie gdy najade na text, a nie na div'a, to samo z zamykaniem. Rozumiem że tu trzeba już coś w css działać?
  1. function menu_open(id){
  2. var div = document.getElementById(id);
  3. div.style.visibility = 'visible';
  4. }
  5.  
  6. function menu_close(id){
  7. var div = document.getElementById(id);
  8. div.style.visibility = 'hidden';
  9. }

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  2. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>str</title>
  6. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  7. <link rel="stylesheet" type="text/css" href="style.css" />
  8. <script src="script.js"type="text/javascript"></script>
  9. </head>
  10.  
  11. <body>
  12. <ul>
  13. <li>
  14. <div onmouseover="menu_close('text');" onmouseout="menu_open('text');" id="text">
  15. <a href="#">Home Page</a>
  16. <a href="#">Home Page</a>
  17. <a href="#">Home Page</a>
  18. <a href="#">Home Page</a>
  19. </div>
  20. </li>
  21. </ul>
  22. </body>
  23. </html>


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
maniana
post 20.04.2012, 21:48:48
Post #2





Grupa: Zarejestrowani
Postów: 207
Pomógł: 44
Dołączył: 18.05.2007

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


Najprostszym rozwiązaniem twojego problemu będzie użycie css, który dopasuje tag a do wymiarów diva :)
Go to the top of the page
+Quote Post
o2w5n778
post 21.04.2012, 09:00:50
Post #3





Grupa: Zarejestrowani
Postów: 235
Pomógł: 0
Dołączył: 10.12.2009

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


ok, z tym sobie już poradziłem.
Ale teraz, od razu po uruchomieniu strony moje menu jest otwarte.


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 12:19