I am trying to sort html elements in JS so that it looks like this 
I have this when you hover over them, they expand with additional information, but only the last one in each line gets this function, and I canβt understand why (I tried for hours), if someone could help me, I would appreciate it.
I will send him the jsfiddle link and my js code bad post here so that it can read, and all the css / html / js code was on jsfiddle, https://jsfiddle.net/b7dt0xwj/
var days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'] //'saturday', "sunday"]; var show = document.getElementsByTagName("tr"); function sortElements(){ // console.log(show) for (var i=0; i<4; i++){ var dayHeader = document.getElementById(days[i]) var showInfo = document.getElementsByClassName("info")[1] // console.log(showInfo) for(var j=0; j<show.length; j++){ if (show[j].getAttribute("day") === dayHeader.getAttribute("id")){ dayHeader.parentNode.insertBefore(show[j], dayHeader.nextSibling); console.log(show[j]) console.log(j) dayHeader.parentNode.insertBefore(showInfo, show[j].nextSibling); } } } }
source share