Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jquery]zmiany klasy po id
trucksweb
post
Post #1





Grupa: Zarejestrowani
Postów: 1 199
Pomógł: 31
Dołączył: 22.03.2004
Skąd: Warszawa

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


czy jest mozliwosc aby zmienic nazwe klasy elementowi po jego wartosci id ?

robie vcos takiego:
  1. var pole = $(this).attr('id');
  2. $(pole).removeClass("kolor");


gdzie pole przyjmuje nazwe id z elementu np. diva, ale juz nie dziala removeClass ? (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
trucksweb
post
Post #2





Grupa: Zarejestrowani
Postów: 1 199
Pomógł: 31
Dołączył: 22.03.2004
Skąd: Warszawa

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


tak, juz poprawilem, ale teraz musze to wszystko zebrac w calos i wyszlo mi cos takiego, co oczywiscie nie dziala (IMG:http://forum.php.pl/style_emoticons/default/dry.gif)
zmienia mi znak - na + ale odwrotnie juz nie chce
i nie wiem dlaczego ale przestala dzialac akcja toggle (IMG:http://forum.php.pl/style_emoticons/default/dry.gif)

  1. $(document).ready (
  2. function()
  3. {
  4. $(".glowna .minus").click(
  5.  
  6. function() {
  7. var pole = $(this).attr('id');
  8. if($(this).attr('class')=='minus')
  9. {
  10. $("#"+pole).removeClass("minus").addClass("plus");
  11.  
  12. $("#ukryj").toggle("fast");
  13. alert(pole);
  14. }
  15.  
  16. }
  17.  
  18. );
  19. $(".glowna .plus").click(
  20.  
  21. function() {
  22. var pole = $(this).attr('id');
  23. if($(this).attr('class')=='plus')
  24. {
  25. $("#"+pole).removeClass("plus").addClass("minus");
  26. $("#ukryj").toggle("fast"); alert(pole);
  27. }
  28.  
  29.  
  30. }
  31.  
  32. );
  33. }
  34. );


zmiana kolor dziala prawidlowo a zbudowana jest na podobnej zasadzie, w dodatku w innym pliku...

Ten post edytował trucksweb 13.10.2008, 23:49:59
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: 11.10.2025 - 03:54