File tree Expand file tree Collapse file tree 4 files changed +21
-22
lines changed
2-ui/1-document/03-dom-navigation
3-navigation-links-which-null Expand file tree Collapse file tree 4 files changed +21
-22
lines changed Original file line number Diff line number Diff line change 1- There are many ways, for instance :
1+ ਇੱਥੇ ਬਹੁਤ ਸਾਰੇ ਤਰੀਕੇ ਹਨ, ਉਦਾਹਰਣ ਵਜੋਂ :
22
3-
4- The ` <div> ` DOM node:
3+ ` <div> ` DOM ਨੋਡ:
54
65``` js
76document .body .firstElementChild
8- // or
7+ // ਜਾਂ
98document .body .children [0 ]
10- // or (the first node is space, so we take 2nd )
9+ // ਜਾਂ (ਪਹਿਲਾ ਨੋਡ ਸਪੇਸ ਹੈ, ਇਸਲਈ ਅਸੀਂ ਦੂਜਾ ਸਥਾਨ ਲੈਂਦੇ ਹਾਂ )
1110document .body .childNodes [1 ]
1211```
1312
14- The ` <ul> ` DOM node :
13+ ` <ul> ` DOM ਨੋਡ :
1514
1615``` js
1716document .body .lastElementChild
1817// or
1918document .body .children [1 ]
2019```
2120
22- The second ` <li> ` (with Pete ):
21+ ਦੂਜਾ ` <li> ` (ਪੀਟ ਨਾਲ ):
2322
2423``` js
25- // get <ul>, and then get its last element child
24+ // ਪ੍ਰਾਪਤ ਕਰੋ <ul>,ਅਤੇ ਫਿਰ ਇਸ ਦਾ ਆਖਰੀ ਏਲੇਮੈਂਟ ਵਾਲਾ ਬੱਚਾ ਪ੍ਰਾਪਤ ਕਰੋ
2625document .body .lastElementChild .lastElementChild
2726```
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ importance: 5
22
33---
44
5- # DOM children
5+ # DOM ਬੱਚੇ
66
7- Look at this page :
7+ ਇਸ ਪੇਜ ਨੂੰ ਵੇਖੋ :
88
99``` html
1010<html >
@@ -18,7 +18,7 @@ Look at this page:
1818</html >
1919```
2020
21- For each of the following, give at least one way of how to access them :
22- - The ` <div> ` DOM node ?
23- - The ` <ul> ` DOM node ?
24- - The second ` <li> ` (with Pete )?
21+ ਹੇਠ ਲਿਖਿਆਂ ਵਿੱਚੋਂ ਹਰੇਕ ਲਈ, ਉਹਨਾਂ ਤੱਕ ਪਹੁੰਚਣ ਦੇ ਤਰੀਕੇ ਦਾ ਘੱਟੋ ਘੱਟ ਇੱਕ ਢੰਗ ਦਿਓ :
22+ - ` <div> ` DOM ਨੋਡ ?
23+ - ` <ul> ` DOM ਨੋਡ ?
24+ - ਦੂਜਾ ` <li> ` (ਪੀਟ ਨਾਲ )?
Original file line number Diff line number Diff line change 1- 1 . Yes, true. The element ` elem.lastChild ` is always the last one, it has no ` nextSibling ` .
2- 2 . No, wrong, because ` elem.children[0] ` is the first child * among elements* . But there may exist non-element nodes before it. So ` previousSibling ` may be a text node .
1+ 1 . ਹਾਂ ਸਹੀ. ਏਲੇਮੈਂਟ ` elem.lastChild ` ਹਮੇਸ਼ਾਂ ਆਖਰੀ ਹੁੰਦਾ ਹੈ, ਇਸਦਾ ਕੋਈ ਸਮਕਸ਼ ਨਹੀਂ ਹੁੰਦਾ ` nextSibling ` .
2+ 2 . ਨਹੀਂ, ਗਲਤ, ਕਿਉਂਕਿ ` elem.children[0] ` ਪਹਿਲਾ ਬੱਚਾ ਹੈ * among elements* . ਪਰ ਇਸ ਤੋਂ ਪਹਿਲਾਂ ਗੈਰ-ਏਲੇਮੈਂਟ ਨੋਡ ਮੌਜੂਦ ਹੋ ਸਕਦੇ ਹਨ. ਇਸ ਲਈ ` previousSibling ` ਟੈਕਸਟ ਨੋਡ ਹੋ ਸਕਦਾ ਹੈ .
33
4- Please note: for both cases if there are no children, then there will be an error .
4+ ਕਿਰਪਾ ਕਰਕੇ ਨੋਟ ਕਰੋ: ਦੋਵਾਂ ਮਾਮਲਿਆਂ ਲਈ ਜੇ ਕੋਈ ਬੱਚੇ ਨਹੀਂ ਹਨ, ਤਾਂ ਏਹ ਇੱਕ ਗਲਤੀ ਹੋਏਗੀ .
55
6- If there are no children , ` elem.lastChild ` is ` null ` , so we can't access ` elem.lastChild.nextSibling ` . And the collection ` elem.children ` is empty (like an empty array ` [] ` ).
6+ ਜੇ ਕੋਈ ਬੱਚੇ ਨਹੀਂ ਹਨ , ` elem.lastChild ` ਹੈ ` null ` , ਇਸ ਲਈ ਅਸੀਂ ਐਕਸੈਸ ਨਹੀਂ ਕਰ ਸਕਦੇ ` elem.lastChild.nextSibling ` . ਅਤੇ ਸੰਗ੍ਰਹਿ ` elem.children ` ਖਾਲੀ ਹੈ (ਖਾਲੀ ਐਰੇ ਵਾਂਗ ` [] ` ).
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ importance: 5
22
33---
44
5- # The sibling question
5+ # ਭੈਣ ਭਰਾ ਸਵਾਲ
66
7- If ` elem ` -- is an arbitrary DOM element node ...
7+ If ` elem ` -- ਇੱਕ ਅਸਥਾਈ DOM ਐਲੀਮੈਂਟ ਨੋਡ ਹੈ ...
88
9- - Is it true that ` elem.lastChild.nextSibling ` is always ` null ` ?
10- - Is it true that ` elem.children[0].previousSibling ` is always ` null ` ?
9+ - ਕੀ ਇਹ ਸੱਚ ਹੈ? ` elem.lastChild.nextSibling ` ਹਮੇਸ਼ਾ ਹੁੰਦਾ ਹੈ ` null ` ?
10+ - ਕੀ ਇਹ ਸੱਚ ਹੈ? ` elem.children[0].previousSibling ` ਹਮੇਸ਼ਾ ਹੁੰਦਾ ਹੈ ` null ` ?
You can’t perform that action at this time.
0 commit comments