Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> removeClass() nie działa
AboutMe
post 20.10.2017, 00:20:50
Post #1





Grupa: Zarejestrowani
Postów: 261
Pomógł: 0
Dołączył: 24.02.2008

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


Dlaczego removeClass() nie działa w poniższym skrypcie?

  1. jQuery(function(){
  2.  
  3. jQuery(".sidenav-members-arrow").click(function(){
  4. jQuery( ".sidenav-members" ).addClass( "sidenav-expand" );
  5. });
  6.  
  7. jQuery(".sidenav-expand .sidenav-members-arrow").click(function(){
  8. jQuery( ".sidenav-members" ).removeClass( "sidenav-expand" );
  9. });
  10.  
  11. });

Go to the top of the page
+Quote Post
Tomplus
post 20.10.2017, 05:35:07
Post #2





Grupa: Zarejestrowani
Postów: 1 831
Pomógł: 225
Dołączył: 20.03.2005
Skąd: Będzin

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


Spróbuj:
Kod
$('.sidenav-expand .sidenav-members-arrow').on('click', function() {
    $( ".sidenav-members" ).removeClass( "sidenav-expand" );
  });

funkcja .ON jest tutaj b.ważna.

Go to the top of the page
+Quote Post
trueblue
post 20.10.2017, 07:27:45
Post #3





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

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


Nie ma to większego sensu. Na kliknięcie wykona się dodanie klasy i usunięcie klasy. Nie zauważysz żadnego efektu.
Ma być jedna obsługa zdarzenia, a w środku obydwie funkcje z if + hasClass lub toggleClass.


--------------------
Go to the top of the page
+Quote Post
AboutMe
post 20.10.2017, 13:09:33
Post #4





Grupa: Zarejestrowani
Postów: 261
Pomógł: 0
Dołączył: 24.02.2008

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


toggleClass zadziałało idealnie smile.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 23:18