Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z addClass i removeClass
di@blo
post
Post #1





Grupa: Zarejestrowani
Postów: 94
Pomógł: 0
Dołączył: 9.03.2005

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


Witam

Dopiero zaczynam pracę z Ajaxem i jQuery. Dotychczas korzystałem z gotowych skryptów jQuery, ale postanowiłem napisać sobie coś sam.
Mam taki skrypt:
  1. <script type="text/javascript">
  2. function show() {
  3. var $factive = $('.galeria img.factive');
  4. var $lactive = $('.galeria img.lactive');
  5.  
  6. $factive.show().removeClass('factive');
  7. $lactive.show().removeClass('lactive');
  8.  
  9. $factive.next().addClass('factive');
  10. $lactive.prev().addClass('lactive');
  11. }
  12.  
  13. $(function() {
  14. $('.galeria img').hide();
  15. setInterval( "show()", 2000 ); });
  16.  
  17. </script>


  1. <div class="galeria">
  2. <img src="images/1.jpg" class="factive" alt="" />
  3. <img src="images/2.jpg" alt="" />
  4. <img src="images/3.jpg" alt="" />
  5. <img src="images/4.jpg" alt="" />
  6. <img src="images/51.jpg" alt="" />
  7. <img src="images/6.jpg" alt="" />
  8. <img src="images/7.jpg" alt="" />
  9. <img src="images/8.jpg" class="lactive" alt="" />
  10. </div>


1. Skryp działa tak, że wykonuje funkcje show(), ale nie wykonuje funkcji removeClass i addClass.
2. Jak dam styl obrazków na display: none, i zamiast funkcji show() dam FadeIn() nie działa nic, ale jak dam opacity: 0.0 i animate() to już jest ok

Przypuszczam, że popełniłem jakiś prosty bład, ale jak napisałem dopiero zaczynam.


EDIT:
Nie nadaje klasy w liniach
$factive.next().addClass('factive');
$lactive.prev().addClass('lactive');
Chociaż jak sprawdzam to istnieje następny i poprzedni element.

Ten post edytował erix 14.03.2011, 14:10:27
Powód edycji: [erix]: przeniosłem
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: 22.08.2025 - 19:23