Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] Problem ze zrozumieniem skryptu., Hellp
maverickkk
post 9.09.2007, 20:08:03
Post #1





Grupa: Zarejestrowani
Postów: 181
Pomógł: 0
Dołączył: 12.11.2005

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


Cześć.

Próbuje zrozumieć działanie skryptu w JavaScript opartym o węzły i nie do konca moge zrozumieć zapis kilku linijek.

  1. <?php
  2. (..)
  3. for (var i = 0; i < document.getElementById(id).getElementsByTagName('dt').length; i++)
  4. {
  5. var dd = new Array();
  6. var el = document.getElementById(id).getElementsByTagName('dt')[i].nextSibling;
  7. var nodeName;
  8.  
  9. while (el && (nodeName = el.nodeName.toLowerCase()) != 'dt')
  10. {
  11. if (nodeName == 'dd')
  12. {
  13. el._dt = document.getElementById(id).getElementsByTagName('dt')[i];
  14. dd[dd.length] = el;
  15. }
  16. el = el.nextSibling;
  17. }
  18.  
  19. document.getElementById(id).getElementsByTagName('dt')[i]._dd = dd;
  20. (...)
  21. ?>


Nie moge zrozumieć do czego słyży zapis w linach 13,14 i 19 i dlaczego wygląda on akurat tak a nie inaczej.

Ten fragment jest uproszcząną werską skryptu z adresu: http://www.kurshtml.boo.pl/skrypty/menu_rozwijane.html który jest oparty na liście definicji: http://www.kurshtml.boo.pl/html/slownik,tekst.html

Ten post edytował maverickkk 10.09.2007, 10:22:39


--------------------
Robie to co lubie, lubie to co Robie
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
sp_
post 10.09.2007, 10:14:01
Post #2





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

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


document.getElementById(id) może zwrócić element, który zawiera w sobie jeszcze inne elementy, które można przeszukiwać.
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: 14.08.2025 - 07:49