Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Usuwanie pozostałych divów
degistivepl
post 8.07.2018, 21:16:37
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 5.04.2018

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


Cześć, zrobiłem coś takiego i 3 pierwsze divy w divie orders-container są przenoszone na koniec a z góry usuwane, a jak zrobić żeby zostały te 3 divy a reszta się usunęła?
  1. var orderscontainer = document.getElementById("orders-container");
  2.  
  3. orderscontainer.addEventListener("click", Show);
  4. elements = orderscontainer.children;
  5. var newelements = [];
  6.  
  7. function Show() {
  8. for (var i=0; i<elements.length; i++)
  9. {
  10. if (i < 3)
  11. {
  12. newelements.push(elements[i]);
  13. }
  14. }
  15. for (var i=0; i<newelements.length; i++) {
  16. orderscontainer.appendChild(newelements[i]);
  17. }
  18. }
Go to the top of the page
+Quote Post

Posty w temacie


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: 29.03.2024 - 12:52