Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jQuery] Zwijanie / rozwijanie najblizszego li
manieks
post
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 16.03.2021

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


Witam

  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $(document).on('click', '.ftpCatalogMinuns', function () {
  4. li.parentElement.slideToggle("slow");
  5. });
  6. });
  7.  
  8. <li id="catalog_administration">
  9. <div id="administration" class="ftpCatalogMinuns"></div>
  10. <div class="ftpCatalogName">administration</div>
  11.  
  12.  


Chciałbym aby po kliknięciu w class="ftpCatalogMinuns" zwineło mi najbliższe li i zmieniło clasę na class="ftpCatalogPlus".
Można prosić o podpowiedź jak to zrobić?

Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
nospor
post
Post #2





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




$(document).ready(function(){
$(document).on('click', '.ftpCatalogMinuns', function () {
$(this).parents("li:first").slideToggle("slow");
});
});
Go to the top of the page
+Quote Post
manieks
post
Post #3





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 16.03.2021

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


Owszem zwija mi ale znika mi całe li administration a chciałem żeby zwineło mi ul poniżej, możesz coś na to poradzić?
Go to the top of the page
+Quote Post
nospor
post
Post #4





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




Ja tam nie widze zadnego ul ponizej
Go to the top of the page
+Quote Post
viking
post
Post #5





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


https://jsfiddle.net/hr89bgt6/
Tylko popraw sobie ten kod html bo sensu nie ma za bardzo.
Go to the top of the page
+Quote Post
manieks
post
Post #6





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 16.03.2021

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


Przepraszam powinienem cały kod dać:
  1.  
  2. <ul id="ftpFile">
  3. <li id="catalog__old">
  4. <div id="_old" class="ftpCatalogPlus"></div>
  5. <div class="ftpCatalogName">_old</div>
  6. </li>
  7.  
  8. <li id="catalog__sql">
  9. <div id="_sql" class="ftpCatalogPlus"></div>
  10. <div class="ftpCatalogName">_sql</div>
  11. </li>
  12.  
  13. <li id="catalog_administration">
  14. <div id="administration" class="ftpCatalogMinuns"></div>
  15. <div class="ftpCatalogName">administration</div>
  16.  
  17. <li class="ftpCatalogLine">
  18. <ul>
  19. <li id="catalog_administration/_portal">
  20. <div id="administration_portal" class="ftpCatalogPlus"></div>
  21. <div class="ftpCatalogName">_portal</div>
  22. </li>
  23. <li id="catalog_administration/class">
  24. <div id="administrationclass" class="ftpCatalogPlus"></div>
  25. <div class="ftpCatalogName">class</div>
  26. </li>
  27.  
  28. ............................
  29.  

Chodzi mi aby po kliknięciu .ftpCatalogMinuns zwineło poniższe ul, źle się wyraziłem na początku.

Pozdrawiam
Go to the top of the page
+Quote Post
nospor
post
Post #7





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




$(document).ready(function(){
$(document).on('click', '.ftpCatalogMinuns', function () {
$(this).parents("li:first").find("ul").hide();
});
});

Ale strukture to masz faktycznie zwalona... od kiedy LI moze miec element LI? UL moze miec LI a nie LI
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: 24.08.2025 - 04:26