+ 2

Why don't they work when I use the terms firstChild, lastChild, previousSibling, nextSibling when working with DOM in JavaScript

Also when working with the commands element.appendChild, element.cloneNode, these also do not run ?!

1st Aug 2020, 7:16 PM
Alireza Jamshidi
Alireza Jamshidi - avatar
3 odpowiedzi
+ 3
No one has any idea about what you are talking but I can tell they work well on sololearn ,maybe go through JavaScript course in here
1st Aug 2020, 7:36 PM
Abhay
Abhay - avatar
+ 2
These transversal also count space , break ,enter ,comment tabs as node. Might you have targeted wrong. Let we have <div> <h1>...</h1> <p>...</p> </div> Now if you target here h1 as firstChild of div it will not work because firstChild is a break/enter . Similarly P is not nextSibling to h1 Consider these point and try again if not work .comment and link your code here I will try for u.
1st Aug 2020, 8:35 PM
Divya Mohan
Divya Mohan - avatar
0
Alireza Jamshidi As you asked me for an examples here I have tried for you. I hope it will be clear to you https://code.sololearn.com/WQbFfCo1nS2C/?ref=app
2nd Aug 2020, 11:14 AM
Divya Mohan
Divya Mohan - avatar