JSFiddle - React, Tailwind, and code Playground

by domenlightenment

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<ul><!-- comment -->
<li id="A"></li>
<li id="B"></li>
</ul>

JavaScript

//cache selection of the ul
var ul = document.querySelector('ul');

//What is the first child of the ul?
console.log(ul.firstElementChild.nodeName); //logs LI

//What is the last child of the ul?
console.log(ul.lastElementChild.nodeName); //logs LI

//What is the nextSibling of the first li?
console.log(document.getElementById('A').nextElementSibling.nodeName); //logs LI

//What is the previousSibling of the last li?
console.log(document.getElementById('B').previousElementSibling.nodeName); //logs LI