Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] appendChild i removeChild
pjamalia
post 10.11.2011, 09:00:22
Post #1





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 1.11.2009

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


Cześć,

Napisałem poniższą funkcję. Wszystko jest ładnie z dodawaniem appendChild. Za każdym razem jak najadę na odnośnik to dane są wyśietlane na warstwie, lecze próbuję od dłuższego czasu zrobić tak, żeby wyświetlane dane po najechaniu na odnośnik nie duplikowały się w wyświetlaniu. Stwierdziłem, że użyję removeChild jak poniżej. Niestety remove nie chcę załapać, poproszę o pomoc w tej robnej kwestii:

  1. function js_showData(div_name,num,div_city,div_object)
  2. {
  3.  
  4. var div = null;
  5. var city = null;
  6. var obj_name = null;
  7. var v0 = null;
  8. var v1 = null;
  9. var v2 = null;
  10. var v3 = null;
  11. div = document.getElementById(div_name);
  12. city = document.getElementById(div_city);
  13. obj_name = document.getElementById(div_object);
  14. var advert_num = num;
  15. if(num == null)
  16. {
  17. num = 0;
  18. }
  19.  
  20. /*
  21.   div.style.width=200;
  22.   div.style.height=200;
  23.   div.style.backgroundColor="black";
  24. div.style.color="white";
  25.   */
  26. if(js_object_name[num]!=null)
  27. {
  28. v0 = document.createTextNode(js_id_adv[num]+" ");
  29. v1 = document.createTextNode(js_object_name[num]+" ");
  30. v2 = document.createTextNode(js_city[num]+" ");
  31. v3 = document.createTextNode(js_area[num]+" ");
  32.  
  33.  
  34. obj_name.appendChild(v1);
  35. city.appendChild(v2);
  36. div.appendChild(v3);
  37.  
  38. div_object.removeChild(v2.lastChild);
  39.  
  40. }
  41. }
  42.  
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: 14.08.2025 - 13:23