Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Jak przerobic ten skrypt
tangor
post
Post #1





Grupa: Zarejestrowani
Postów: 20
Pomógł: 0
Dołączył: 1.05.2013

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


Mam taki skrypt:
  1. <div id="galeria">
  2. <a class="showSingle" target="1">Motocykle</a>
  3. <a class="showSingle" target="2">Auta</a>
  4. <a class="showSingle" target="3">ATV/quady</a>
  5. <a class="showSingle" target="4">Łodzie</a>
  6.  
  7. <div id="div1" class="targetDiv" style="display: block;"></div>
  8. <div id="div2" class="targetDiv" style="display: none;"></div>
  9. <div id="div3" class="targetDiv" style="display: none;"></div>
  10. </div>
  11.  
  12. <script type="text/javascript">
  13. jQuery(function(){
  14. jQuery('.showSingle').click(function(){
  15. var item = $(this);
  16. var vis = jQuery('.targetDiv:visible');
  17. var targetItem = item.attr('target');
  18. var target = jQuery('#div' + targetItem);
  19. var fn = function() {
  20. target.fadeIn('slow');
  21. };
  22. if (vis.length) {
  23. if (vis[0].id == "div" + targetItem) {
  24. fn = function() {};
  25. }
  26. vis.fadeOut(fn);
  27.  
  28. } else {
  29. target.fadeIn(slow);
  30. }
  31. });
  32. });



po kliknieciu w target1 pojawia sie div1, ale kiedy znow klikne w target1- div1 znika(i nie da sie juz nic wlaczyc), co zrobic, aby po kliknieciu w target1 pojawil sie div1, ale aby juz nic nie moglo zniknac, tylko mozna bylo kliknac w target2 i pojawial sie div 2, tak samo z target3 i div3.
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 561
Pomógł: 6315
Dołączył: 27.12.2004




Kod
jQuery(function(){

   jQuery('.showSingle').click(function(){

       var item = $(this);

       var vis = jQuery('.targetDiv:visible');

       var targetItem = item.attr('target');

       var target = jQuery('#div' + targetItem);
target.show();

   });

});
Go to the top of the page
+Quote Post
tangor
post
Post #3





Grupa: Zarejestrowani
Postów: 20
Pomógł: 0
Dołączył: 1.05.2013

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


Troche zlie to wytlumaczylem, chodzi mi o efekt, ktory daje ten skrypt:
(demo):
http://perishablepress.com/demos/slide-fade-content/
Tylko zalezy mi na tym by nie uzywac ajax, bo na popdstronach ladowanych ajaxem nie dziala jquery. Myslalem zeby skrypt zmienial display w css danego obiektu.
Szukam juz kilka dni rozwiazania na to, a nie znam jquery, wiec prosze o pomoc.
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: 18.12.2025 - 23:08