Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] Po kliknięciu w menu strona przeskakuje na samą góre.
Micchaleq
post 13.03.2012, 19:05:34
Post #1





Grupa: Zarejestrowani
Postów: 186
Pomógł: 4
Dołączył: 13.10.2009

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


Witam serdecznie,

Nie bardzo wiem jak się to konkretnie nazywa, ale chciałbym jakoś wyłączyć przeskakiwanie strony na górę po kliknięciu w menu.

Konkretnie mam menu wykonane w jQuery z toogle i po kliknęciu jeżeli była przewinięta strona, przewija mi na samą górę.

Proszę o podpowiedź jak to zrobić aby strona zostawała w aktualnym miejscu?


--------------------
Go to the top of the page
+Quote Post
viking
post 13.03.2012, 19:09:45
Post #2





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


return false;

lub event.preventDefault();


--------------------
Go to the top of the page
+Quote Post
lobopol
post 13.03.2012, 19:10:10
Post #3





Grupa: Zarejestrowani
Postów: 1 729
Pomógł: 346
Dołączył: 4.04.2009

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


Na zdarzeniu click dla tego linku preventdefault trzeba dać


--------------------
Go to the top of the page
+Quote Post
Micchaleq
post 13.03.2012, 19:15:40
Post #4





Grupa: Zarejestrowani
Postów: 186
Pomógł: 4
Dołączył: 13.10.2009

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


mam coś takiego

  1. $(".internet").click(function()
  2. {
  3. if(menu != "internet"){
  4. hide();
  5. $('.internet_menu_bot').toggle(10);
  6. $('.internet_menu').toggle(10);
  7. menu = "internet";
  8. }else{
  9. $('.internet_menu_bot').toggle(10);
  10. $('.internet_menu').toggle(10);
  11. menu = "internet";
  12. }
  13. }
  14. );


--------------------
Go to the top of the page
+Quote Post
lobopol
post 13.03.2012, 19:20:36
Post #5





Grupa: Zarejestrowani
Postów: 1 729
Pomógł: 346
Dołączył: 4.04.2009

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


dodaj do tego return false na końcu albo w function() wstaw function(e) i na końcu
[JAVASCRIPT] pobierz, plaintext
  1. e.preventDefault();
[JAVASCRIPT] pobierz, plaintext


--------------------
Go to the top of the page
+Quote Post
Micchaleq
post 13.03.2012, 19:22:21
Post #6





Grupa: Zarejestrowani
Postów: 186
Pomógł: 4
Dołączył: 13.10.2009

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


Dziękuje


--------------------
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 - 06:31