2

Greetings fellow coder,

I'm reading a book about JS ( beginners edition ) . I am on previous and next sibling properties.

I'm a little confused. I'm trying to run this demo code:

var el = document.getElementById('two');

When I console.log(el.nextSibling); it shows #text.

When I use console.log(el.nextElementSibling); it shows the correct results which is the next li element: <li id="three" class="hot">honey</li>

In the book it's saying that using .nextSibling will jump to the next Sibling element which it doesn't. Can someone explain me the difference?

Thank you!

Ben
  • 54,723
  • 49
  • 178
  • 224
  • yea maybe, so i guess the book is wrong on that subject and its confusing the reader because its explaining that it should jump to the next element . But the nextSibling it jump to the next node – Christodoulou Andreas Aug 16 '16 at 22:36

0 Answers0