Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][JavaScript]Zmiana menu bez przeładowania, index.html#nazwa
Johnas
post
Post #1





Grupa: Zarejestrowani
Postów: 650
Pomógł: 16
Dołączył: 5.07.2010
Skąd: Ściśle Tajne

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


Witam! Mam taki prosty skrypt:
[JAVASCRIPT] pobierz, plaintext
  1. $(document).ready(function() {
  2.  
  3. var hash = window.location.hash.substr(1);
  4. var href = $('#nav li a').each(function(){
  5. var href = $(this).attr('href');
  6. if(hash==href.substr(0,href.length-5)){
  7. var toLoad = hash+'.html #content';
  8. $('#content').load(toLoad)
  9. }
  10. });
  11.  
  12. $('#nav li a').click(function(){
  13.  
  14. var toLoad = $(this).attr('href')+' #content';
  15. $('#content').hide('fast',loadContent);
  16. $('#load').remove();
  17. $('#wrapper').append('<span id="load">LOADING...</span>');
  18. $('#load').fadeIn('normal');
  19. window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
  20. function loadContent() {
  21. $('#content').load(toLoad,'',showNewContent())
  22. }
  23. function showNewContent() {
  24. $('#content').show('normal',hideLoader());
  25. }
  26. function hideLoader() {
  27. $('#load').fadeOut('normal');
  28. }
  29. return false;
  30.  
  31. });
  32.  
  33. });
[JAVASCRIPT] pobierz, plaintext

Zastanawia mnie jak w tym menu:
  1. <div id="pos">
  2. <ul class="menu" id="nav">
  3. <li><a class="active" href="index.html"><span><span><span>Filmy</span></span></span> </a></li>
  4. <li><a href="gry.html"><span><span><span>Gry</span></span></span> </a></li>
  5. <li><a href="#"><span><span><span>Muzyka</span></span></span> </a></li>
  6. </ul>
  7. </div>

Zrobić klasę aktywną czyli do <a> dodać class="active"

Ten post edytował Jonek_1993 4.09.2011, 10:21:28
Go to the top of the page
+Quote Post

Posty w temacie


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: 23.12.2025 - 14:20