1 //method one
2 var c = document.getElementById("myDIV").childNodes;
3 c[1].style.backgroundColor = "yellow";//first child
4 c[2].style.backgroundColor = "red";//second child
5 c[-1].style.backgroundColor = "green";//last child
6 c[-2].style.backgroundColor = "blue";//secound last child
7//method two
8 let nth-child = document.querySeletorAll('myDiv:nth-child(n)');//gives nth child
1//you can use the css nth-child property like this:
2var second-child = document.querySeletorAll('[your element name]:nth-child(2)');