What is the easiest way to swap the order of child nodes?
For example I want childNode[3] to be childNode[4] and vice-versa.
Try this method:
Get the parent element
two elements you want to swap
Store the .nextSibling of the node that is last in order eg: [1,2,3,4] => we want to swap 3 & 2 then store nextSibling of 3, '4'.
.nextSibling of the node that is last in order
.insertBefore(3,2);