![]() |
![]() |
![]() ![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 157 Pomógł: 5 Dołączył: 3.03.2004 Ostrzeżenie: (0%) ![]() ![]() |
Aż wstyd pytać, jednakże po całkiem długim czasie wracam do js
![]() Mam taką zmienną: Kod var filterVal = $(this).text().toLowerCase().replace('tekst A','tekst B'); Prosta funkcja, która odnajduje tekst 1 i zmienia na drugi. Chciałbym ją rozwinąć o więcej tekstów do podmiany,czyli by jednocześnie Kod var filterVal = $(this).text().toLowerCase().replace('tekst A','tekst B'); var filterVal = $(this).text().toLowerCase().replace('tekst C','tekst D'); Oczywiście w powyższym przykładzie zostanie zastosowana tylko ostatnia opcja, zatem tutaj robią się schody. Spróbowałem wpakować to w funkcję: Kod function filterVal() { $(this).text().toLowerCase().replace(' tekst A','tekst B'); $(this).text().toLowerCase().replace(' tekst C','tekst D'); } Ale po podmianie wszędzie fiterVal na filterVal() kod się nie wykonywał. Ktoś poradzi, jak upchać parę zmian tekstów w jedną zmienną, etc? Tutaj wrzucam całość kodu będącego częścią jquery Pretty photo (zaznaczyłem to wrażliwe miejsce): Kod $(document).ready(function() { /* Pretty Photo */ $(\"a[rel^='gazeta']\").prettyPhoto({ counter_separator_label: '/', /* The separator for the gallery counter 1 of 2 */ theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */ horizontal_padding: 20, /* The padding on each side of the picture */ hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */ wmode: 'opaque', /* Set the flash wmode attribute */ autoplay: true, /* Automatically start videos: True/False */ modal: false, /* If set to true, only the close button will close the window */ deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */ default_width: 1020, default_height: 704, social_tools: false, overlay_gallery: false, show_title: false, }); /* Pretty Photo */ /* filtrowanie zawartości */ $('ul#filter a').click(function() { $(this).css('outline','none'); $('ul#filter .current').removeClass('current'); $(this).parent().addClass('current'); /************************************************* TUTAJ JEST TEN ELEMENT **/ var filterVal = $(this).text().toLowerCase().replace('TREŚĆ A','TREŚĆ B'); /************************************************* TUTAJ JEST TEN ELEMENT **/ if(filterVal == 'all') { $('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden'); } else { $('ul#portfolio li').each(function() { if(!$(this).hasClass(filterVal)) { $(this).fadeOut('normal').addClass('hidden'); } else { $(this).fadeIn('slow').removeClass('hidden'); } }); } return false; }); }); Kod jest częścią skryptu jquery Pretty Photo -------------------- Kliknij na "POMÓGŁ", by poprawić mi samopoczucie :D
|
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 14.08.2025 - 15:25 |