Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [javascript] kasowanie elementów
nmts
post
Post #1





Grupa: Zarejestrowani
Postów: 283
Pomógł: 34
Dołączył: 21.03.2008

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


  1. <div id="content_normal">
  2. <div class="message" style="margin-top: 291px; margin-left: 163px; color: rgb(113,117,136);">Good morning:)</div>
  3. <div class="message" style="margin-top: 170px; margin-left: 332px; color: rgb(154,130,83);">Hello</div>
  4. <div class="message" style="margin-top: 295px; margin-left: 401px; color: rgb(127,79,106);">Hi !</div>
  5. <div class="message" style="margin-top: 389px; margin-left: 63px; color: rgb(129,77,78);">Hey sexy</div>
  6. </div>


Na stronie dynamicznie generuje się taki kod. Próbuje wykasować wszystkie divy z content_normal w następujący sposób:

  1. var content = document.getElementById('content_normal');
  2. var messagesA = content.getElementsByTagName('div');
  3. for(var i=0; i<messagesA.length; i++)
  4. {
  5. content.removeChild(messagesA.item(i));
  6. }


Kasuje to za każdym razem tą samą część divów. Gdy w pętli zrobię item(0), to kasuje też za każdym razem część (inną) divów.
Być może czegoś nie rozumiem i źle coś robię, w takim razie czego nie rozumiem? (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)

Ten post edytował nmts 16.07.2009, 18:44:17
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: 25.12.2025 - 14:14