on https://www.apis.de/dienstleistungen/trainings/ I have several accordions. Within these are tables with dates and other info. each has an ID generated serverside (php). I want to simply grab the tbody tag using the selector path (dev tools) --> get the children nodes and switch e.g. node[11] and node[12] around. The problem is that the JS function i wrote does not get recognized because the accordion is closed on page load and doesn't recognize the selector path (using an IIFE)
(function(){
let first_table = document.querySelector("#site-wrapper > div > div > main > article > section > ul > li.is-expanded > ul > li > table > tbody"); // gets the tbody of first accordion (Schulungen Deutschland)
console.log(first_table); // returns null, because the accordion was not open when the function is executed.
})();